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.

Reply via email to