ansible 学习6

ansible模块常用的有command和shell模块,通过 -m参数指定使用的模块,默认使用command模块,shell模块比默认模块功能强大。

 -m copy  拷贝模块

 -m  file模块 新建目录,递归删除文件,修改文件权限

[root@localhost ~]# ansible webservers -m file -a "dest=/tmp/abcd state=directory"
192.168.10.128 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"gid": 0,
"group": "root",
"mode": "0755",
"owner": "root",
"path": "/tmp/abcd",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 6,
"state": "directory",
"uid": 0
}
192.168.10.127 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"gid": 0,
"group": "root",
"mode": "0755",
"owner": "root",
"path": "/tmp/abcd",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 6,
"state": "directory",
"uid": 0
}

posted @ 2021-07-14 15:35  beawh  阅读(31)  评论(0编辑  收藏  举报