我有一个tar / gzip文件,我使用ansible unarchive模块解压缩到主机列表。
以下是configs.tgz的部分内容列表:
-rw-rw-r-- ian/ian 1295 2015-09-25 15:27 Makefile
-rw-rw-r-- ian/ian 16 2016-06-21 09:24 .configs
drwxrwxr-x ian/ian 0 2016-02-24 10:18 .bash/
-rw-rw-r-- ian/ian 336 2015-09-25 15:27 .bash/apt.b
-rw-rw-r-- ian/ian 367 2015-09-25 15:27 .bash/gcloud.b
drwxrwxr-x ian/ian 0 2016-06-21 09:22 .vim/
drwxrwxr-x ian/ian 0 2016-06-21 09:22 .vim/plugin/
-rw-rw-r-- ian/ian 3327 2016-06-21 09:17 .vim/plugin/scratch.vim
drwxrwxr-x ian/ian 0 2015-09-25 15:27 .vim/ftplugin/
-rw-rw-r-- ian/ian 521 2015-09-25 15:27 .vim/ftplugin/dokuwiki.vim
-rw-rw-r-- ian/ian 2456 2015-09-25 15:27 .vim/ftplugin/nagios.vim
drwxrwxr-x ian/ian 0 2015-09-25 15:27 .vim/ftdetect/
-rw-rw-r-- ian/ian 149 2015-09-25 15:27 .vim/ftdetect/nagios.vim
-rw-rw-r-- ian/ian 111 2015-09-25 15:27 .vim/ftdetect/zsh-profile.vim
-rw-rw-r-- ian/ian 554 2015-09-25 15:27 .zshrc
drwxrwxr-x ian/ian 0 2015-09-25 15:27 .mutt/
lrwxrwxrwx ian/ian 0 2015-09-25 15:27 .mutt/profile.active -> profile.gmail
-rw-rw-r-- ian/ian 863 2015-09-25 15:27 .mutt/everyone.lst
-rw-rw-r-- ian/ian 310 2015-09-25 15:27 .mutt/vimrc4mail
-rw-rw-r-- ian/ian 11559 2015-09-25 15:27 .mutt/muttrc
-rw-rw-r-- ian/ian 441 2015-09-25 15:27 .screenrc
-rw-rw-r-- ian/ian 131 2015-09-25 15:27 .tmux.conf
-rwxrwxr-x ian/ian 1439 2015-09-25 15:27 xmake
我想提取除了 .mutt
目录之外的所有内容,但我似乎无法使排除选项正常工作。
这是我得到的:
% ansible --version
ansible 2.1.0.0
config file = /home/ian/Playbooks/ansible.cfg
configured module search path = Default w/o overrides
% rm -rf /tmp/a; mkdir /tmp/a && ansible localhost -m unarchive -a "src=configs/configs.tgz dest=/tmp/a/ exclude='.mutt'" -vvv
Using /home/ian/Playbooks/ansible.cfg as config file
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: ian
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1466558533.54-272347310038797 `" && echo ansible-tmp-1466558533.54-272347310038797="` echo $HOME/.ansible/tmp/ansible-tmp-1466558533.54-272347310038797 `" ) && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1466558533.64-181689590644032 `" && echo ansible-tmp-1466558533.64-181689590644032="` echo $HOME/.ansible/tmp/ansible-tmp-1466558533.64-181689590644032 `" ) && sleep 0'
<localhost> PUT /tmp/tmp9TwX54 TO /home/ian/.ansible/tmp/ansible-tmp-1466558533.64-181689590644032/stat
<localhost> EXEC /bin/sh -c 'LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /home/ian/.ansible/tmp/ansible-tmp-1466558533.64-181689590644032/stat; rm -rf "/home/ian/.ansible/tmp/ansible-tmp-1466558533.64-181689590644032/" > /dev/null 2>&1 && sleep 0'
<localhost> PUT configs/configs.tgz TO /home/ian/.ansible/tmp/ansible-tmp-1466558533.54-272347310038797/source
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1466558533.94-189956548033565 `" && echo ansible-tmp-1466558533.94-189956548033565="` echo $HOME/.ansible/tmp/ansible-tmp-1466558533.94-189956548033565 `" ) && sleep 0'
<localhost> PUT /tmp/tmp2xgO6E TO /home/ian/.ansible/tmp/ansible-tmp-1466558533.94-189956548033565/unarchive
<localhost> EXEC /bin/sh -c 'LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /home/ian/.ansible/tmp/ansible-tmp-1466558533.94-189956548033565/unarchive; rm -rf "/home/ian/.ansible/tmp/ansible-tmp-1466558533.94-189956548033565/" > /dev/null 2>&1 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/ian/.ansible/tmp/ansible-tmp-1466558533.54-272347310038797/ > /dev/null 2>&1 && sleep 0'
localhost | FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"backup": null,
"content": null,
"copy": true,
"creates": null,
"delimiter": null,
"dest": "/tmp/a/",
"directory_mode": null,
"exclude": [
".mutt"
],
"extra_opts": [],
"follow": false,
"force": null,
"group": null,
"keep_newer": false,
"list_files": false,
"mode": null,
"original_basename": "configs.tgz",
"owner": null,
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/home/ian/.ansible/tmp/ansible-tmp-1466558533.54-272347310038797/source"
}
},
"msg": "path /tmp/a/.mutt/profile.active does not exist",
"path": "/tmp/a/.mutt/profile.active",
"state": "absent"
}
我已尝试过&#34;排除&#34;的各种迭代。选项,包括
exclude='[ ".mutt" ]'
exclude='[ ".mutt", ".mutt/*" ]'
这些似乎有效,但我总是最终得到正在提取的.mutt
目录的全部内容。
我哪里错了?
答案 0 :(得分:1)
根据评论,此问题已记录错误。
解决方法是使用YAML列表作为排除项,并确保列表与存档中存储的路径/文件完全匹配。
vars:
exclusions:
- ./.mutt
和
unarchive: src=configs/configs.tgz dest=/tmp/a exclude={{ exclusions }}