Re: [ansible-project] How to use 'with_items' based on variable?

2018-12-28 Thread James Cassell
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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
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.


[ansible-project] How to use 'with_items' based on variable?

2018-12-28 Thread Bharath Kumar
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
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.


Re: [ansible-project] How to set timeout value for a task using shell module?

2018-12-28 Thread S C Rigler
Assuming the target machine is running a modern Linux version, you can
run the "timeout" command in your shell.

Like:

- shell: timeout -s 9 10 /usr/bin/command that does something

That will send a "kill -9" to the command if it doesn't finish in 10 seconds.

On Fri, Dec 28, 2018 at 10:53 AM Saravanan  wrote:
>
> Hi Ansible Experts,
> We are running tasks using shell module. Sometime these tasks are pending due 
> to backend application server slow response. Is there anyway to set timeout 
> for these tasks to exit after certain time period?
>
> Regards
> Saravanan
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/53713c72-2f3d-4865-b105-6c25844e07b5%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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFbiokc1ZsJP0apU_erOVmhc87K2qMMZCFG%2B9YRaKndG_Z1YiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to set timeout value for a task using shell module?

2018-12-28 Thread Piyush Bansal
Have u explored async mode ??

On Fri 28 Dec, 2018, 10:23 PM Saravanan  Hi Ansible Experts,
> We are running tasks using shell module. Sometime these tasks are pending
> due to backend application server slow response. Is there anyway to set
> timeout for these tasks to exit after certain time period?
>
> Regards
> Saravanan
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/53713c72-2f3d-4865-b105-6c25844e07b5%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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BLLie4kaHMUEeosEmWd%3Da%3DoeyOhuCKx%3DNfnEoH_Gb_07aZzMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] How to set timeout value for a task using shell module?

2018-12-28 Thread Saravanan
Hi Ansible Experts,
We are running tasks using shell module. Sometime these tasks are pending 
due to backend application server slow response. Is there anyway to set 
timeout for these tasks to exit after certain time period?

Regards
Saravanan

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/53713c72-2f3d-4865-b105-6c25844e07b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Task history (per host)

2018-12-28 Thread Jimmy Htor
Just wanted to let you know that I implemented sth: 
https://github.com/NotAProfessionalDeveloper/ansible-tools/tree/master/ara_host_history

It's a little crude since it uses the ARA DB directly, however the ARA CLI 
doesn't seem to provide all the necessary data in such an easy way.
I must also admit that I only found out about the CLI later, so I might 
give it another try some time. But for now it works.

Have fun

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a6e59d4e-c433-4718-a6f6-34900b9d4fe3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.