Thanks.

And is there a way to not use include and to keep the inner loop into the 
same playbook than the outer loop?
Cause I don't like the way it splits the playbook into two yaml files.



Le mercredi 29 mars 2017 10:42:29 UTC+2, Kai Stian Olstad a écrit :
>
> On 28.03.2017 11:44, Z-obaze wrote: 
> > Hi, 
> > 
> > I'm finally stuck with another case. 
> > 
> > Sometimes I could get something like this : 
> > 
> > ok: [server1] => { 
> >>     "requirements": { 
> >>         "changed": false, 
> >>         "msg": "All items completed", 
> >>         "results": [ 
> >>             { 
> >>                 "_ansible_item_result": true, 
> >>                 "_ansible_no_log": false, 
> >>                 "_ansible_parsed": true, 
> >>                 "changed": false, 
> >>                 "invocation": { 
> >>                     "module_args": { 
> >>                         "conf_file": null, 
> >>                         "disable_gpg_check": false, 
> >>                         "disablerepo": null, 
> >>                         "enablerepo": null, 
> >>                         "exclude": null, 
> >>                         "install_repoquery": true, 
> >>                         "list": "first_package", 
> >>                         "name": null, 
> >>                         "state": "installed", 
> >>                         "update_cache": false, 
> >>                         "validate_certs": true 
> >>                     }, 
> >>                     "module_name": "yum" 
> >>                 }, 
> >>                 "item": "first_package", 
> >>                 "results": [ 
> >>                     { 
> >>                         "arch": "x86_64", 
> >>                         "epoch": "0", 
> >>                         "name": "name_of_the_package", 
> >>                         "nevra": "0:first_package", 
> >>                         "release": "release_of_the_package", 
> >>                         "repo": "repo", 
> >>                         "version": "version_of_the_package", 
> >>                         "yumstate": "available" 
> >>                     } 
> >>                     { 
> >>                         "arch": "x86_64", 
> >>                         "epoch": "0", 
> >>                         "name": "name_of_the_package", 
> >>                         "nevra": "0:first_package", 
> >>                         "release": "release_of_the_package", 
> >>                         "repo": "installed", 
> >>                         "version": "version_of_the_package", 
> >>                         "yumstate": "installed" 
> >>                     } 
> >>                 ] 
> >>             }, 
> >>             { 
> >>                 "_ansible_item_result": true, 
> >>                 "_ansible_no_log": false, 
> >>                 "_ansible_parsed": true, 
> >>                 "changed": false, 
> >>                 "invocation": { 
> >>                     "module_args": { 
> >>                         "conf_file": null, 
> >>                         "disable_gpg_check": false, 
> >>                         "disablerepo": null, 
> >>                         "enablerepo": null, 
> >>                         "exclude": null, 
> >>                         "install_repoquery": true, 
> >>                         "list": "second_package", 
> >>                         "name": null, 
> >>                         "state": "installed", 
> >>                         "update_cache": false, 
> >>                         "validate_certs": true 
> >>                     }, 
> >>                     "module_name": "yum" 
> >>                 }, 
> >>                 "item": "second_package", 
> >>                 "results": [ 
> >>                     { 
> >>                         "arch": "x86_64", 
> >>                         "epoch": "0", 
> >>                         "name": "name_of_the_package", 
> >>                         "nevra": "0:second_package", 
> >>                         "release": "release_of_the_package", 
> >>                         "repo": "repo", 
> >>                         "version": "version_of_the_package", 
> >>                         "yumstate": "available" 
> >>                     } 
> >>                  ] 
> >> 
> > 
> > So here, I have two results for the same package. 
> > With the tip you gave me, I can only look into the first one, I know I 
> > could add "item.results.1.yumstate" but I don't want to cause I could 
> > get 
> > more than 2 results. 
> > 
> > I tried with the "with_subelements" but it split the array by the 
> > number of 
> > results I have and in that case I want to compare 
> > "item.results.0.yumstate" 
> > and "item.results.1.yumstate"? But as I said I could get more. 
>
> To do this you need a loop in a loop. 
>
> Put the inner most loop in a yaml file and use include with with_itmes 
> to loop the outer item and use loop_control to change the variable name. 
> https://docs.ansible.com/ansible/playbooks_loops.html#loop-control 
>
> -- 
> Kai Stian Olstad 
>

-- 
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/8509c6c6-cd60-4b47-909f-1c75284cddd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to