无法获得“排除"使用 unarchive 模块的选项 [英] Unable to get "exclude" option working with unarchive module
问题描述
我有一个 tar/gzip 文件,我正在使用 ansible unarchive 模块将其解压缩到主机列表中.
I have a tar/gzip file I am extracting to a list of hosts using the ansible unarchive module.
以下是configs.tgz的部分内容列表:
The following is a partial list of the contents of 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
目录,但我似乎无法让排除选项正常工作.
I'd like to extract everything except the .mutt
directory, but I can't seem to get the exclude option to work correctly.
这是我得到的:
% 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"
}
我尝试了排除"选项的各种迭代,包括
I've tried various iterations of the "exclude" option, including
exclude='[ ".mutt" ]'
exclude='[ ".mutt", ".mutt/*" ]'
这些似乎有效,但我总是以提取 .mutt
目录的全部内容结束.
These appear to work, but I always end up with the entire contents of the .mutt
directory being extracted.
我哪里出错了?
推荐答案
根据评论,此问题记录了一个错误.
Per the comments, there is a bug logged for this issue.
解决方法是对排除项使用 YAML 列表,并确保该列表与存档中存储的路径/文件完全匹配.
The work-around is to use a YAML list for the exclusions and to make sure the list exactly matches the path/file stored in the archive.
vars:
exclusions:
- ./.mutt
和
unarchive: src=configs/configs.tgz dest=/tmp/a exclude={{ exclusions }}
这篇关于无法获得“排除"使用 unarchive 模块的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!