0

The task includes an option with an undefined variable. The error was: ansible_all_ipv4_addresses is undefined.

Why would I be getting this error, if I am connecting over ipv4? I'm trying to dump this like,

"{{ ansible_all_ipv4_addresses[0] }}"

And I can verify that it is valid,

$ ansible -u centos -m setup 10.1.38.15 | grep ansible_all_ipv4_addresses -A2 -B1
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "172.16.0.13"
        ],

But then very similar to the above,

$ ansible -u centos -m debug -a "msg='{{ansible_all_ipv4_addresses}}'" 10.1.38.15
10.1.38.15 | FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'ansible_all_ipv4_addresses' is undefined"
}
  • Have you tried using "{{ ansible_host }}"? – Panki Jan 10 at 8:25
1

For me the problem was that my playbook had

gather_facts: false

Set at the top of my playbook. As to why the use of facts does not work with the debug module, for that see this question

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.