当前位置:网站首页>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
其他
如有问题 欢迎补充
如有疑问 欢迎提出
如有作用 欢迎点赞
边栏推荐
- @Controller, @service, @repository, @component differences
- MySQL完全卸载(Windows、Mac、Linux)
- Isn't there anyone who doesn't know how to write mine sweeping games in C language
- Mysql34 other database logs
- Global and Chinese market for intravenous catheter sets and accessories 2022-2028: Research Report on technology, participants, trends, market size and share
- Navicat 導出錶生成PDM文件
- Mysql25 index creation and design principles
- NPM an error NPM err code enoent NPM err syscall open
- Mysql35 master slave replication
- Mysql21 - gestion des utilisateurs et des droits
猜你喜欢
Csdn-nlp: difficulty level classification of blog posts based on skill tree and weak supervised learning (I)
【博主推荐】SSM框架的后台管理系统(附源码)
Opencv uses freetype to display Chinese
Esp8266 at+cipstart= "", "", 8080 error closed ultimate solution
Mysql26 use of performance analysis tools
MySQL transaction log
Bytetrack: multi object tracking by associating every detection box paper reading notes ()
Other new features of mysql18-mysql8
Mysql33 multi version concurrency control
MySQL27-索引優化與查詢優化
随机推荐
SSM整合笔记通俗易懂版
Adaptive Bezier curve network for real-time end-to-end text recognition
MySQL34-其他数据库日志
Isn't there anyone who doesn't know how to write mine sweeping games in C language
【博主推荐】C#MVC列表实现增删改查导入导出曲线功能(附源码)
Yum prompt another app is currently holding the yum lock; waiting for it to exit...
【博主推荐】C#生成好看的二维码(附源码)
IDEA 导入导出 settings 设置文件
MySQL31-MySQL事务日志
Mysql36 database backup and recovery
windows下同时安装mysql5.5和mysql8.0
Nanny hand-in-hand teaches you to write Gobang in C language
++Implementation of I and i++
Pytorch LSTM实现流程(可视化版本)
MySQL18-MySQL8其它新特性
【博主推荐】asp.net WebService 后台数据API JSON(附源码)
CSDN question and answer module Title Recommendation task (II) -- effect optimization
[untitled]
Timestamp with implicit default value is deprecated error in MySQL 5.6
CSDN博文摘要(一) —— 一个简单的初版实现