Hey guys,
I'm trying to write an ansible playbook with the shell module. In the
command, I'm want to use the eth1 interface if it exists. If the eth1
interface doesn't exist, it should fallback to the loopback interface.
My initial approach was to use the defaulting undefined variables as
follows:
shell: docker run -d -p {{ ansible_eth1.ipv4.address | default(127.0.0.1)
}}:27017:27017 [...] dockerfile/mongodb
Unfortunately, Ansible threw the following error:
fatal: [server] => One or more undefined variables: 'ansible_eth1' is
undefined
I also tried versions of this, such as:
shell: docker run -d -p {{ ansible_eth1.ipv4.address |
ansible_lo.ipv4.address }}:27017:27017 [...] dockerfile/mongodb
That gave me another error:
failed: [server] => {"changed": true, "cmd": "docker run -d -p {#
ansible_eth1.ipv4.address | ansible_lo.ipv4.address #}:27017:27017 [...]",
"delta": "0:00:00.021053", "end": "2014-11-01 17:22:04.457375", "rc":
127, "start": "2014-11-01 17:22:04.436322"}
stderr: /bin/sh: 1: ansible_lo.ipv4.address: not found
2014/11/01 17:22:04 Invalid containerPort: {{
Could anyone help point me in the right direction?
I've also published this on Serverfault [1]:
http://serverfault.com/questions/641326/issues-with-ansibles-default-error-handling-in-a-playbook
--
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/ad7a8411-abbe-46b9-bff7-a9a122eb115d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.