发表于 2018-7-29 06:48:50

ansible 之file模块

# useradd boy  # useradd boy
  # ansible slave -m file -a "dest=/tmp/txt01 mode=755 owner=boy group=boy" -s
  client02 | SUCCESS => {
  "changed": true,
  "gid": 500,
  "group": "boy",
  "mode": "0755",
  "owner": "boy",
  "path": "/tmp/txt01",
  "size": 6,
  "state": "file",
  "uid": 500
  }
  agent.test.com | SUCCESS => {
  "changed": true,
  "gid": 501,
  "group": "boy",
  "mode": "0755",
  "owner": "boy",
  "path": "/tmp/txt01",
  "size": 6,
  "state": "file",
  "uid": 501
  }
  否则报错:
  # ansible slave -m file -a "dest=/tmp/txt01 mode=755 owner=boy group=boy" -s
  agent.test.com | FAILED! => {
  "changed": false,
  "failed": true,
  "gid": 0,
  "group": "root",
  "mode": "0644",
  "msg": "chown failed: failed to look up user boy",
  "owner": "root",
  "path": "/tmp/txt01",
  "size": 6,
  "state": "file",
  "uid": 0
  }
  client02 | FAILED! => {
  "changed": false,
  "failed": true,
  "gid": 0,
  "group": "root",
  "mode": "0644",
  "msg": "chown failed: failed to look up user boy",
  "owner": "root",
  "path": "/tmp/txt01",
  "size": 6,
  "state": "file",
  "uid": 0
  }
  # ll txt01
  -rwxr-xr-x 1 boy boy 6 Jul 30 20:50 txt01
  # ll txt01
  -rwxr-xr-x 1 boy boy 6 Jul 30 20:50 txt01
页: [1]
查看完整版本: ansible 之file模块