{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible-tw/AMA/issues/13","repository_url":"https://api.github.com/repos/ansible-tw/AMA","labels_url":"https://api.github.com/repos/ansible-tw/AMA/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/ansible-tw/AMA/issues/13/comments","events_url":"https://api.github.com/repos/ansible-tw/AMA/issues/13/events","html_url":"https://github.com/ansible-tw/AMA/issues/13","id":204797609,"number":13,"title":"在task中，使用 Register 自定二個變數，要在同一個task裡去執行","user":{"login":"zarr12steven","id":1249357,"avatar_url":"https://avatars.githubusercontent.com/u/1249357?v=3","gravatar_id":"","url":"https://api.github.com/users/zarr12steven","html_url":"https://github.com/zarr12steven","followers_url":"https://api.github.com/users/zarr12steven/followers","following_url":"https://api.github.com/users/zarr12steven/following{/other_user}","gists_url":"https://api.github.com/users/zarr12steven/gists{/gist_id}","starred_url":"https://api.github.com/users/zarr12steven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zarr12steven/subscriptions","organizations_url":"https://api.github.com/users/zarr12steven/orgs","repos_url":"https://api.github.com/users/zarr12steven/repos","events_url":"https://api.github.com/users/zarr12steven/events{/privacy}","received_events_url":"https://api.github.com/users/zarr12steven/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-02T07:01:36Z","updated_at":"2017-02-02T07:01:36Z","closed_at":null,"body":"### OS Environment\r\n\r\n```\r\nCentOS Linux release 7.3.1611 (Core)\r\n```\r\n\r\n### Ansible Version\r\n\r\n```\r\nansible 2.2.0.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n### task.yml\r\n\r\n```\r\n- name: Get Blob Name Path\r\n  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'\r\n  register: blobname\r\n\r\n- name: Get Tar File Name\r\n  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\r\n  register: tarfilename\r\n\r\n- name: Download {{ restorebuildnumber.content }}.tar.gz\r\n  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 }}\r\n  with_together:\r\n    -  \"{{ blobname.stdout_lines }}\"\r\n    -  \"{{ tarfilename.stdout_lines }}\"\r\n```\r\n\r\n\r\n這個的重點是用 `with_together` 就可以達成目的了\r\n\r\nReference:\r\n\r\n* [looping-over-parallel-sets-of-data](http://docs.ansible.com/ansible/playbooks_loops.html#looping-over-parallel-sets-of-data)"}}
{"actor":{"display_login":"zarr12steven"}}