Try

files: "{{ lookup('vars', dir ~ '_files' }}"

V/r,
James Cassell

On Fri, Dec 28, 2018, at 3:03 PM, Bharath Kumar wrote:
> Hello Ansible Experts,
> 
> I am creating a Role, which has a task to download multiple files from an 
> URL, and, for that, I am using get_url module. Since, get_url cant download 
> files recursively, I have been trying to use 'with_items'.
> 
> Role Snippets Below.
> 
> /defaults/main.yml
> ---
> 
> files: "{{ dir }}_files"
> 
> 
> /vars/main.yml
> ---
> onedir_files:
>  - abc1
>  - abc2
>  - abc3
> 
> 
> twodir_files:
>  - xyz1
>  - xyz2
> 
> 
> threedir_files:
>  - one
>  - two
>  - three
> 
> /tasks/main.yml
> ---
> - name: Download Properties Files!
>   get_url:
>     url: "{{ url }}/{{ dir }}/{{ item }}"
>     dest: "{{ dest_dir }}/"
>   with_items: "{{ files }}"
> 
> *ansible-playbook test.yml --extra-vars "dir=one"*
> 
> Running all tasks fine until the get_url, and, failing with below.
> 
> failed: [target_host] (item=onedir_files) => {"changed": false, "dest": 
> "/some/target/path", "gid": 0, "group": "root", "item": "onedir_files", 
> "mode": "0755", "msg": "Request failed", "owner": "root", "response": "HTTP 
> Error 404: org.tmatesoft.svn.core.SVNException: svn: E175007: Path 
> '/some/path/", "secontext": "unconfined_u:object_r:default_t:s0", "size": 
> 4096, "state": "directory", "status_code": 404, "uid": 0, "url": 
> "https://someurl/one/onedir_files"}
> 
> Please let me know where I have gone wrong? or, a best practice or a good 
> approach for the above problem/requirement. 
> 
> Thanks in Advance.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/0802a1f2-169c-4695-a26a-9e6ec31a8216%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1546030060.1204343.1620217840.118606B4%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to