OS Environment
CentOS Linux release 7.3.1611 (Core)
Ansible Version
ansible 2.2.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
task.yml
- name: Get Blob Name Path
shell: az storage blob list -o table -c {{ BLOB_CONTAINER }} --account-name {{ backup_account }} --account-key {{ backup_key }} | grep -Eo '{{restorebuildnumber.content}}.tar.gz|{{ restorebuildnumber.content }}/*/.*.gz'
register: blobname
- name: Get Tar File Name
shell: az storage blob list -o table -c {{ BLOB_CONTAINER }} --account-name {{ backup_account }} --account-key {{ backup_key }} | grep -Eo '{{restorebuildnumber.content}}.tar.gz|{{ restorebuildnumber.content }}/*/.*.gz' | cut -d'/' -f3
register: tarfilename
- name: Download {{ restorebuildnumber.content }}.tar.gz
shell: az storage blob download -c {{ BLOB_CONTAINER }} -n {{ item.0 }} -f /tmp/{{restorebuildnumber.content}}/{{ item.1 }} --account-name {{ backup_account }} --account-key {{ backup_key }}
with_together:
- "{{ blobname.stdout_lines }}"
- "{{ tarfilename.stdout_lines }}"
這個的重點是用
with_together
就可以達成目的了
Reference:
沒有留言:
張貼留言