Closed ful09003 closed 6 years ago
Adding another task in roles/ansible-haproxy/tasks/main.yml
to register the Droplet's Anchor IP from the DigitalOcean metadata service, and using that in the jinja template will resolve this, and allows us to continue through the chapter.
Seeing this in ch05 as well (task for ansible-galera-lb : configure haproxy service for galera
)
Re-tested with Ansible 2.5.8, and can confirm this behavior still exists:
ansible-playbook --version
ansible-playbook 2.5.8 (stable-2.5 36fd4a2255) last updated 2018/08/29 16:48:46 (GMT +000)
config file = /root/navigators-guide/example-code/02-scale/ch04/haproxy_loadbalancer/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /root/ansible/lib/ansible
executable location = /root/ansible/bin/ansible-playbook
python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]
TASK [ansible-haproxy : configure haproxy service] *********************************************************************************************************************************************************
fatal: [104.248.64.120]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible_eth0_2' is undefined"}
fatal: [142.93.87.190]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible_eth0_2' is undefined"}
Looking back through facts that Ansible is learning, it appears the anchor IP is exposed as ansible_eth0_1 versus ansible_eth0_2. Instead of needing to add a new task, should just need a template update.
Can you test on an older Droplet if you happen to have one to see if it reports ansible_eth0_2
? I'm curious if something changed with the image/deployments on our side.
Was able to test on Debian 9.3, still reported as eth0_1. I'll make a PR to just update the jinja template.
adjusted defaults/main.yml and templates/haproxy.cfg.j2 7bf7820
passed test. closing
Replicated a few times now: TASK [ansible-haproxy : configure haproxy service] ***** fatal: [142.93.83.70]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible_eth0_2' is undefined"} fatal: [142.93.83.63]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible_eth0_2' is undefined"}
PLAY RECAP ***** 142.93.83.63 : ok=35 changed=33 unreachable=0 failed=1 142.93.83.64 : ok=1 changed=0 unreachable=0 failed=0 142.93.83.69 : ok=1 changed=0 unreachable=0 failed=0 142.93.83.70 : ok=35 changed=33 unreachable=0 failed=1 142.93.90.3 : ok=1 changed=0 unreachable=0 failed=0 159.89.220.217 : ok=1 changed=0 unreachable=0 failed=0
Looks like ansible_eth0_2 really isn't defined:
ansible -i /usr/local/bin/terraform-inventory all -m setup --tree /tmp/facts > /tmp/ansible-debug
grep -C 3 ansible_eth0_2 /tmp/ansible-debug
(empty)grep -C 3 ansible_eth0_1 /tmp/ansible-debug
(lots of hits for Droplet private IPs)Steps to replicate:
ansible-playbook -i /usr/local/bin/terraform-inventory site.yml