当前位置:网站首页>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
其他
如有问题 欢迎补充
如有疑问 欢迎提出
如有作用 欢迎点赞
边栏推荐
- Solve the problem that XML, YML and properties file configurations cannot be scanned
- Mysql21 user and permission management
- 【博主推荐】SSM框架的后台管理系统(附源码)
- Kubernetes - problems and Solutions
- Opencv uses freetype to display Chinese
- [C language] deeply analyze the underlying principle of data storage
- API learning of OpenGL (2005) gl_ MAX_ TEXTURE_ UNITS GL_ MAX_ TEXTURE_ IMAGE_ UNITS_ ARB
- Case identification based on pytoch pulmonary infection (using RESNET network structure)
- A trip to Macao - > see the world from a non line city to Macao
- IDEA 导入导出 settings 设置文件
猜你喜欢
MySQL23-存儲引擎
MySQL35-主从复制
[C language foundation] 04 judgment and circulation
[Li Kou 387] the first unique character in the string
Use JUnit unit test & transaction usage
1. Mx6u learning notes (VII): bare metal development (4) -- master frequency and clock configuration
Pytorch LSTM实现流程(可视化版本)
MySQL24-索引的数据结构
Nanny hand-in-hand teaches you to write Gobang in C language
Mysql27 - Optimisation des index et des requêtes
随机推荐
How to find the number of daffodils with simple and rough methods in C language
Timestamp with implicit default value is deprecated error in MySQL 5.6
MySQL35-主从复制
Bytetrack: multi object tracking by associating every detection box paper reading notes ()
MySQL transaction log
MySQL21-用户与权限管理
Database middleware_ MYCAT summary
MySQL29-数据库其它调优策略
MySQL21-用戶與權限管理
Mysql22 logical architecture
Google login prompt error code 12501
Texttext data enhancement method data argument
Pytoch LSTM implementation process (visual version)
[paper reading notes] - cryptographic analysis of short RSA secret exponents
【博主推荐】C#MVC列表实现增删改查导入导出曲线功能(附源码)
C语言标准的发展
Are you monitored by the company for sending resumes and logging in to job search websites? Deeply convinced that the product of "behavior awareness system ba" has not been retrieved on the official w
windows无法启动MYSQL服务(位于本地计算机)错误1067进程意外终止
February 13, 2022-2-climbing stairs
windows下同时安装mysql5.5和mysql8.0