copy:copy=no为源tar包从被控端解压。 copy=tes 为源tar包从主控端解压
src:源tar包路径
dest:解压到的目标位置
mode:解压后的文件权限https://www.cndba.cn/hbhe0316/article/19209https://www.cndba.cn/hbhe0316/article/19209https://www.cndba.cn/hbhe0316/article/19209
- [root@ansible tmp]# ansible mysql -m unarchive -a 'src=/root/logs.tar.gz dest=/tmp copy=no'
- 192.168.56.88 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "dest": "/tmp",
- "extract_results": {
- "cmd": [
- "/usr/bin/gtar",
- "--extract",
- "-C",
- "/tmp",
- "-z",
- "-f",
- "/root/logs.tar.gz"
- ],
- "err": "",
- "out": "",
- "rc": 0
- },
- "gid": 0,
- "group": "root",
- "handler": "TgzArchive",
- "mode": "01777",
- "owner": "root",
- "size": 4096,
- "src": "/root/logs.tar.gz",
- "state": "directory",
- "uid": 0
- }
解压的时候加权限https://www.cndba.cn/hbhe0316/article/19209https://www.cndba.cn/hbhe0316/article/19209https://www.cndba.cn/hbhe0316/article/19209https://www.cndba.cn/hbhe0316/article/19209https://www.cndba.cn/hbhe0316/article/19209
https://www.cndba.cn/hbhe0316/article/19209
https://www.cndba.cn/hbhe0316/article/19209
- [root@ansible tmp]# ansible mysql -m unarchive -a 'src=/root/logs.tar.gz dest=/tmp mode=777 copy=no'
- 192.168.56.88 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "dest": "/tmp",
- "extract_results": {
- "cmd": [
- "/usr/bin/gtar",
- "--extract",
- "-C",
- "/tmp",
- "-z",
- "-f",
- "/root/logs.tar.gz"
- ],
- "err": "",
- "out": "",
- "rc": 0
- },
- "gid": 0,
- "group": "root",
- "handler": "TgzArchive",
- "mode": "01777",
- "owner": "root",
- "size": 4096,
- "src": "/root/logs.tar.gz",
- "state": "directory",
- "uid": 0
- }
版权声明:本文为博主原创文章,未经博主允许不得转载。
ansible