I tried to run the "first extended playbook" from the Ansible documentation site https://docs.ansible.com/ansible/latest/network/getting_started/first_playbook.html. The playbook does the following:
- Gather facts from a VyOS router
- Debug to print ansible_net_hostname
- Change the host name
- Gather facts again.
- Debug to print the updated host name
After I updated the host name, the ansible_net_hostname variable was unchanged. Upon investigation I found the following:
- The hostname was change (verified by logging into router)
- I got the same results with Cisco IOS.
- If I run the vyos_facts in a second playbook I see the updated host name
- If I run setup before I gather the facts the second time, I still get the original name
- Same if I run meta: clear_facts
- If I run clear_facts but do not gather facts a second time, the fact is cleared and I get an error on the second debug msg, as expected.
- If I run pause for 10 seconds after the update, I still see the old valiue
So why does the second invocation of vyos_facts still return the original value?
Environment:
- Docker container under Ubuntu 20.04
- Ansible 2.9.6
- Python 3.8.5