当前位置:网站首页>Ansible实战系列三 _ task常用命令
Ansible实战系列三 _ task常用命令
2022-07-06 09:13:00 【hyh123a】
前言
记录一下常用的ansible task中常用命令
注意记录时间和版本号
--- 记录于 2021年8月
环境
ubuntu 20.04
ansible 2.9.20
官方文档
https://docs.ansible.com/ansible/latest/user_guide/index.html
1、脚本相关
- 执行shell
- name: Add route
command: /sbin/ip route add 10.250.129.0/24 dev eth0
2、文件文本相关
- 复制
- name: Copy sources.list
copy:
src: sources.list.stretch
dest: /etc/apt/sources.list
- 修改文字
- name: Update monit service
lineinfile:
path: /etc/init.d/monit
regexp: '^CONFIG='
line: 'CONFIG=/root/monitrc'
- 删除文件
- name: Remove tunnel service
file:
path: /etc/systemd/system/node-exporter-tunnel.service
state: absent
3、安装卸载相关
- 安装
- name: Install tcpdump
apt:
name: tcpdump
update_cache: yes
- 卸载
- name: Uninstall ntpd
apt:
name: ntp
state: absent
4、服务相关
- 设置开机自启动
- name: Enable systemd-timesyncd service
systemd:
name: systemd-timesyncd
state: restarted
enabled: yes
daemon_reload: yes
- 关闭开机自启动
- name: Disable autossh-tunnel service
systemd:
name: autossh-tunnel
state: stopped
enabled: no
daemon_reload: yes
ignore_errors: yes
- 重启服务
- name: Restart journald service
systemd:
name: systemd-journald
state: restarted
5、 其他
- 设置时区
- name: Set timezone to Asia/Shanghai
timezone:
name: Asia/Shanghai
- 添加定时任务
- name: Add cronjob
cron:
name: "cell_mgmt.sh"
user: root
job: "/root/cell_mgmt.sh | sponge /root/cell_mgmt.prom"
cron_file: /etc/crontab
其他
如有问题 欢迎补充
如有疑问 欢迎提出
如有作用 欢迎点赞
边栏推荐
- Time in TCP state_ The role of wait?
- Water and rain condition monitoring reservoir water and rain condition online monitoring
- MySQL 29 other database tuning strategies
- Why is MySQL still slow to query when indexing is used?
- CSDN question and answer tag skill tree (I) -- Construction of basic framework
- CSDN问答模块标题推荐任务(二) —— 效果优化
- Navicat 導出錶生成PDM文件
- Global and Chinese market of operational amplifier 2022-2028: Research Report on technology, participants, trends, market size and share
- A brief introduction to the microservice technology stack, the introduction and use of Eureka and ribbon
- February 13, 2022-3-middle order traversal of binary tree
猜你喜欢
Mysql32 lock
Emotional classification of 1.6 million comments on LSTM based on pytoch
Mysql36 database backup and recovery
MySQL25-索引的创建与设计原则
CSDN Q & a tag skill tree (V) -- cloud native skill tree
CSDN问答模块标题推荐任务(一) —— 基本框架的搭建
【博主推荐】C#MVC列表实现增删改查导入导出曲线功能(附源码)
MySQL29-数据库其它调优策略
MySQL36-数据库备份与恢复
Win10: how to modify the priority of dual network cards?
随机推荐
Other new features of mysql18-mysql8
Some problems in the development of unity3d upgraded 2020 VR
Navicat 導出錶生成PDM文件
解决扫描不到xml、yml、properties文件配置
MySQL36-数据库备份与恢复
API learning of OpenGL (2004) gl_ TEXTURE_ MIN_ FILTER GL_ TEXTURE_ MAG_ FILTER
La table d'exportation Navicat génère un fichier PDM
A brief introduction to the microservice technology stack, the introduction and use of Eureka and ribbon
MySQL33-多版本并发控制
MySQL23-存储引擎
MySQL27-索引优化与查询优化
Mysql 其他主机无法连接本地数据库
CSDN问答标签技能树(二) —— 效果优化
Global and Chinese market of wafer processing robots 2022-2028: Research Report on technology, participants, trends, market size and share
Mysql28 database design specification
Database middleware_ MYCAT summary
What is the difference between TCP and UDP?
在jupyter NoteBook使用Pytorch进行MNIST实现
[untitled]
CSDN博文摘要(一) —— 一个简单的初版实现