It should be repos_extra_installed.results[0].stat.exists. It's more complicated because you're doing a with_items on the task that does the register. So each item in that list will have a separate entry in the repos_extra_installed.results list.
On Sat, Sep 13, 2014 at 2:15 AM, Patrick Ansible-ML <[email protected]> wrote: > Hi, > > I have a task which checks if some files exist and does a register. In the > next task, how do I access the exists: [false|true] result for use in > 'when:'? I tried variations of things like this: > 'repos_extra_installed.results.stats.exists == false' > but I always get an error. > > group_vars: > > repos_extra_repos: > - repos_extra_name: internal > repos_extra_file: internal.repo > repos_extra_key: RPM-GPG-KEY-internal > > task: > > - name: repos | Check if extra repos are already installed > stat: > path: /etc/yum.repos.d/{{ item.repos_extra_file }} > with_items: repos_extra_repos > register: repos_extra_installed > > - debug: var=repos_extra_installed > > Debug output: > > TASK: [common | debug var=repos_extra_installed] > ****************************** > ok: [test.local] => { > "repos_extra_installed": { > "changed": false, > "msg": "All items completed", > "results": [ > { > "changed": false, > "invocation": { > "module_args": "", > "module_name": "stat" > }, > "item": { > "repos_extra_file": "internal.repo", > "repos_extra_key": "RPM-GPG-KEY-internal", > "repos_extra_name": "internal" > }, > "stat": { > "exists": false > } > } > ] > } > } > > > Thanks, > Patrick > > -- > 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/5413E11D.805%40puzzled.xs4all.nl. > 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/CAJQqANdNZ4yUzW37kOH7bBUmrUw4ZozMWD88jyOv2c0mEue2cQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
