当前位置:网站首页>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
其他
如有问题 欢迎补充
如有疑问 欢迎提出
如有作用 欢迎点赞
边栏推荐
- 虚拟机Ping通主机,主机Ping不通虚拟机
- 导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法
- API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T
- A trip to Macao - > see the world from a non line city to Macao
- Record the first JDBC
- Database middleware_ MYCAT summary
- MySQL 20 MySQL data directory
- [BMZCTF-pwn] 11-pwn111111
- MySQL30-事务基础知识
- 数据库中间件_Mycat总结
猜你喜欢

Mysql21 - gestion des utilisateurs et des droits

Mysql22 logical architecture

Mysql30 transaction Basics

Swagger、Yapi接口管理服务_SE

【博主推荐】asp.net WebService 后台数据API JSON(附源码)

MySQL34-其他数据库日志

Idea import / export settings file

MySQL21-用户与权限管理

Other new features of mysql18-mysql8

Mysql21 user and permission management
随机推荐
Swagger、Yapi接口管理服务_SE
Pytorch LSTM实现流程(可视化版本)
Database middleware_ MYCAT summary
A brief introduction to the microservice technology stack, the introduction and use of Eureka and ribbon
[paper reading notes] - cryptographic analysis of short RSA secret exponents
First blog
Anaconda3 安装cv2
Have you mastered the correct posture of golden three silver four job hopping?
Google login prompt error code 12501
Global and Chinese market for intravenous catheter sets and accessories 2022-2028: Research Report on technology, participants, trends, market size and share
Advantages and disadvantages of evaluation methods
February 13, 2022-3-middle order traversal of binary tree
Why is MySQL still slow to query when indexing is used?
NPM an error NPM err code enoent NPM err syscall open
CSDN-NLP:基于技能树和弱监督学习的博文难度等级分类 (一)
Discriminant model: a discriminant model creation framework log linear model
Unicode decodeerror: 'UTF-8' codec can't decode byte 0xd0 in position 0 successfully resolved
MySQL26-性能分析工具的使用
Breadth first search rotten orange
MySQL flush operation