ansible模块-替换模块
ansible查看帮助方法
# 查看所有模块帮助信息
ansible-doc -l   
# 指定查看某个模块参数用法
ansible-doc copy  
1.lineinfile模块
ansible all -m lineinfile -a "path=/root/hehe regexp='^user admin' line='user hehe'"
lineinfile模块参数
| 参数 | 说明 | 
|---|---|
| path | 文件路径 | 
| regexp | 匹配的规则,即要替换的内容 | 
| line | 替换为什么 | 
| state | absent 删除 | 
2.replace模块
ansible all -m replace -a "path=/root/hehe regexp='^user admin' replace='hehe'"
replace模块参数
| 参数 | 说明 | 
|---|---|
| path | 文件路径 | 
| regexp | 匹配的规则,即要替换的内容 | 
| replace | 替换为什么 | 

