Ansible:一组在复制唯一的文件到每个服务器 [英] Ansible: copying one unique file to each server in a group
问题描述
我有一系列的编号文件要由每个服务器分开处理。使用Linux进行分割,然后XZ COM pressed,以节省传输时间每个分割文件进行。
split_001 split_002 split_003 ... split_030
我怎么可以把这些文件出一组具有ansible 30台服务器?不要紧哪个服务器获取的文件,只要他们每个人都有一个唯一的文件。
我用了一个bash文件,但我正在寻找一个更好的解决方案。希望使用ansible。然后,我打算运行shell命令来运行在命令开始计算的几个小时或几天。
SCP -oStrictHostKeyChecking =无bt_5869_001.xz usr13 @<知识产权及GT;:/数据/
SCP -oStrictHostKeyChecking =无bt_5869_002.xz usr13 @<知识产权及GT;:/数据/
SCP -oStrictHostKeyChecking =无bt_5869_003.xz usr13 @<知识产权及GT;:/数据/
...
http://docs.ansible.com/ansible/copy_module.html
#复制文件,但遍历各分割文件
- 副本:SRC = /我的/ split_001.xz DEST = /数据/ split_001.xz
- 副本:SRC = /我的/计算DEST = /数据/所有者=根模式= 0755
- 副本:SRC = /我的/ start.sh DEST = /数据/所有者=根模式= 0755
- 外壳:XZ-D * .xz
- 贝:在-f /data/start.sh现在
例如:
任务:
- set_fact:
padded_host_index:{{'{0:03D}'格式(play_hosts.index(inventory_hostname))}} - 副本:SRC = /我的/分_ {{padded_host_index}} XZ DEST = /数据/
I have a series of numbered files to be processed separately by each server. Each split file made using linux split and then xz compressed to save transfer time.
split_001 split_002 split_003 ... split_030
How can I push these files out to a group of 30 servers with ansible? It does not matter which server gets which file so long as they each have a single unique file.
I had used a bash file but I am looking for a better solution. Hopefully using ansible. Then I plan to run a shell command to run an at command to start the several hours or days of computation.
scp -oStrictHostKeyChecking=no bt_5869_001.xz usr13@<ip>:/data/
scp -oStrictHostKeyChecking=no bt_5869_002.xz usr13@<ip>:/data/
scp -oStrictHostKeyChecking=no bt_5869_003.xz usr13@<ip>:/data/
...
http://docs.ansible.com/ansible/copy_module.html
# copy file but iterate through each of the split files
- copy: src=/mine/split_001.xz dest=/data/split_001.xz
- copy: src=/mine/compute dest=/data/ owner=root mode=0755
- copy: src=/mine/start.sh dest=/data/ owner=root mode=0755
- shell: xz -d *.xz
- shell: at -f /data/start.sh now
For example:
tasks:
- set_fact:
padded_host_index: "{{ '{0:03d}'.format(play_hosts.index(inventory_hostname)) }}"
- copy: src=/mine/split_{{ padded_host_index }}.xz dest=/data/
这篇关于Ansible:一组在复制唯一的文件到每个服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!