2
我有一個tar/gzip文件,我正在使用非歸檔模塊提取到主機列表。無法使用取消歸檔模塊獲得「排除」選項
以下是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"
}
我已經試過了「排除」選項的各種迭代,包括
exclude='[ ".mutt" ]'
exclude='[ ".mutt", ".mutt/*" ]'
這些看起來工作,但我總是落得正在提取.mutt
目錄的全部內容。
我哪裏錯了?
你試過用不同的檔案類型 - .ZIP,.BZ?是gunzip,bunzip等安裝? 又如何指定.mutt的絕對路徑,即「/.mutt」或「/.mutt/」。 – Rowley
最新的ansible版本包含排除和strip-components的[issues](https://github.com/ansible/ansible-modules-core/issues/3988)。 –
@Rowley對於延遲迴復感到抱歉,感謝您的幫助。我試過zip,bz2和未壓縮的tar,結果相同。我發現我需要一個YAML列表,如@ Konstantin-Suvorov鏈接的錯誤報告中所述,並且您關於絕對路徑的建議使我發現條目需要**完全匹配存檔中的那些條目 - 「./ .mutt'在我的情況。 –