Ansible - 复制是否支持 shell * 扩展
Ansible - Does copy support shell * expansion
Ansible 1.9.2/更新版本。
剧本:
# Push Performance tests artifact zip file on remote jmeter machine
- name: Push Performance tests artifact zip file on remote jmeter machine
copy: src="performance-tests-*.zip" dest={{ common_download_dir }}
它出错了:
19:32:08 TASK: [perf_tests | Push Performance tests artifact zip file on remote jmeter machine] ***
19:32:08 fatal: [jmeter01.server.in.vcloud] => input file not found at /home/service/workspace/run-project-performance-tests/build/artifacts/roles/perf_tests/files/performance-tests-*.zip or /home/service/workspace/run-project-performance-tests/build/artifacts/performance-tests-*.zip
19:32:08
19:32:08 FATAL: all hosts have already failed -- aborting
我检查了源机器(我是 运行 ansible),工作区有有效文件:performance-tests-0.0.8-20151001.232123-11.zip
在像copy: src="somePath/*.zip" dest="somePathOnRemoteMachine"
这样的复制操作期间,ansible不支持shell扩展,即* in src=参数(到所有文件)?
Ansible 站点上的所有示例:https://docs.ansible.com/ansible/copy_module.html 显示.. src=... 参数只有一个文件。
PS: 我没有在复制模块中使用验证参数。
没有。
我想最简单的方法是使用 shell 模块,然后直接发出 cp
命令。
您可以使用 http://docs.ansible.com/ansible/playbooks_loops.html#looping-over-fileglobs with_fileglob 匹配单个目录中的所有文件,非递归地匹配模式。可以这样使用::
# copy each file over that matches the given pattern
- copy: src={{ item }} dest=/etc/fooapp/ owner=root mode=600
with_fileglob:
- /playbooks/files/fooapp/*
Ansible 1.9.2/更新版本。
剧本:
# Push Performance tests artifact zip file on remote jmeter machine
- name: Push Performance tests artifact zip file on remote jmeter machine
copy: src="performance-tests-*.zip" dest={{ common_download_dir }}
它出错了:
19:32:08 TASK: [perf_tests | Push Performance tests artifact zip file on remote jmeter machine] ***
19:32:08 fatal: [jmeter01.server.in.vcloud] => input file not found at /home/service/workspace/run-project-performance-tests/build/artifacts/roles/perf_tests/files/performance-tests-*.zip or /home/service/workspace/run-project-performance-tests/build/artifacts/performance-tests-*.zip
19:32:08
19:32:08 FATAL: all hosts have already failed -- aborting
我检查了源机器(我是 运行 ansible),工作区有有效文件:performance-tests-0.0.8-20151001.232123-11.zip
在像copy: src="somePath/*.zip" dest="somePathOnRemoteMachine"
这样的复制操作期间,ansible不支持shell扩展,即* in src=参数(到所有文件)?
Ansible 站点上的所有示例:https://docs.ansible.com/ansible/copy_module.html 显示.. src=... 参数只有一个文件。
PS: 我没有在复制模块中使用验证参数。
没有。
我想最简单的方法是使用 shell 模块,然后直接发出 cp
命令。
您可以使用 http://docs.ansible.com/ansible/playbooks_loops.html#looping-over-fileglobs with_fileglob 匹配单个目录中的所有文件,非递归地匹配模式。可以这样使用::
# copy each file over that matches the given pattern
- copy: src={{ item }} dest=/etc/fooapp/ owner=root mode=600
with_fileglob:
- /playbooks/files/fooapp/*