Ok. Did not realize that we can use Jinja2 statement blocks right along 
with the modules and it doesn't always have to just a variable expression. 
Was able to do this by templating.

Regards
Abhishek 

On Wednesday, July 8, 2015 at 5:21:33 PM UTC-7, Abhishek R. wrote:
>
> Hi folks,
>
> Need some help related to registered variables.
>
> The first task in my playbook performs some operations over a nested loop 
> and I'm registering a variable for its results. The variable looks like 
> this  -
>
> "n_init": {
>             "changed": true, 
>             "failed": true, 
>             "msg": "One or more items failed.", 
>             "results": [
>                 {
>                     "changed": true, 
>                     ----
>                     "item": [
>                         "host1.abc.com", 
>                         "1098"
>                     ],
>                     ----
>                 },
>                 {
>                     "changed": true, 
>                     ----
>                     "item": [
>                         "host2.abc.com", 
>                         "1098"
>                     ],
>                     ----
>                 },
>                 ----
>                 {
>                     "changed": true, 
>                     ----
>                     "item": [
>                         "host10.abc.com", 
>                         "1098"
>                     ],
>                     ----
>                 }    
>             ]    
>         }
>
> In my second task, I need to execute a script and need to pass two 
> parameters to it, both derived from the above variable. The two parameters 
> should have contents like this -
>
> param1 (string) - "host1.abc.com:host2.abc.com:...:host10.abc.com"
> param2 (json array) - [{"host":"host1.abc.com","port":"1098"},{"host":"
> host2.abc.com","port":"1098"},...,{"host":"host10.abc.com","port":"1098"}]
>
> I've tried out few Jinja2 filters and Ansible looping constructs, but am 
> unable to get these values off the registered variable. Any suggestions?
>
> Thanks in advance
>
> Regards
> Abhishek
>

-- 
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/82d4857e-916a-43e8-9447-757fae4b5ab7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to