|
#批量添加软连接
[iyunv@root localhost]#ansible web
-m file -a 'src=/tmp/fstab dest=/tmp/fstab.link state=link'
172.16.252.143 | SUCCESS => {
"changed": true,
"dest": "/tmp/fstab.link",
"gid": 0,
"group": "root",
"mode": "0777",
"owner": "root",
"size": 10,
"src": "/tmp/fstab",
"state": "link",
"uid": 0
}
172.16.253.177 | SUCCESS => {
"changed": true,
"dest": "/tmp/fstab.link",
"gid": 0,
"group": "root",
"mode": "0777",
"owner": "root",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 10,
"src": "/tmp/fstab",
"state": "link",
"uid": 0
}
172.16.254.47 | SUCCESS => {
"changed": true,
"dest": "/tmp/fstab.link",
"gid": 0,
"group": "root",
"mode": "0777",
"owner": "root",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 10,
"src": "/tmp/fstab",
"state": "link",
"uid": 0
}
172.16.252.182 | SUCCESS => {
"changed": true,
"dest": "/tmp/fstab.link",
"gid": 0,
"group": "root",
"mode": "0777",
"owner": "root",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 10,
"src": "/tmp/fstab",
"state": "link",
"uid": 0
}
[iyunv@~ localhost]#ll /tmp
-rw-r--r--. 1 tom tom 595 Jul 6 21:52 fstab
lrwxrwxrwx. 1 root root 10 Jul 6 22:20 fstab.link -> /tmp/fstab
#批量创建目录:state是directory
[iyunv@root localhost]#ansible web -m file -a 'path=/tmp/tomtest/ state=directory mode=0755'
172.16.252.143 | SUCCESS => {
"changed": true,
"gid": 0,
"group": "root",
"mode": "0755",
"owner": "root",
"path": "/tmp/tomtest/",
"size": 4096,
"state": "directory",
"uid": 0
}
172.16.254.47 | SUCCESS => {
"changed": true,
"gid": 0,
"group": "root",
"mode": "0755",
"owner": "root",
"path": "/tmp/tomtest/",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 6,
"state": "directory",
"uid": 0
}
172.16.253.177 | SUCCESS => {
"changed": true,
"gid": 0,
"group": "root",
"mode": "0755",
"owner": "root",
"path": "/tmp/tomtest/",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 6,
"state": "directory",
"uid": 0
}
172.16.252.182 | SUCCESS => {
"changed": true,
"gid": 0,
"group": "root",
"mode": "0755",
"owner": "root",
"path": "/tmp/tomtest/",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 6,
"state": "directory",
"uid": 0
}
[iyunv@~ localhost]#ll /tmp
drwxr-xr-x. 2 root root 6 Jul 6 22:26 tomtest
#批量创建文件: state=touch
[iyunv@root localhost]#ansible web -m file -a 'path=/tmp/ansible mode=0644 state=touch'
172.16.252.143 | SUCCESS => {
"changed": true,
"dest": "/tmp/ansible",
"gid": 0,
"group": "root",
"mode": "0644",
"owner": "root",
"size": 0,
"state": "file",
"uid": 0
}
172.16.254.47 | SUCCESS => {
"changed": true,
"dest": "/tmp/ansible",
"gid": 0,
"group": "root",
"mode": "0644",
"owner": "root",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 0,
"state": "file",
"uid": 0
}
172.16.252.182 | SUCCESS => {
"changed": true,
"dest": "/tmp/ansible",
"gid": 0,
"group": "root",
"mode": "0644",
"owner": "root",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 0,
"state": "file",
"uid": 0
}
172.16.253.177 | SUCCESS => {
"changed": true,
"dest": "/tmp/ansible",
"gid": 0,
"group": "root",
"mode": "0644",
"owner": "root",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 0,
"state": "file",
"uid": 0
}
[iyunv@~ localhost]#ll /tmp
total 8
-rw-r--r--. 1 root root 0 Jul 6 22:30 ansible |
|