I have a DHCP Rhel 8.6 in Azure system that runs cloud-init at each boot. I want to change the obtained DNS servers at each boot for a specific DNS. But I want to do it in ansible. My question is why the following ansible does not persist after each reboot?
- hosts: localhost become: yes tasks: - name: setting DNS resolver config, remove default DNS as it is not my DC ip address nmcli: conn_name='System eth0' dns4="10.1.1.38" dns4_ignore_auto=true dns4_search="dclabs.labs.lab" state=present autoconnect=true - name: restart NetworkManager service service: name=NetworkManager state=restarted
After each reboot, my changes are reverted and I am back to have in /etc/resolv.conf the DHCP obtained DNS entries.
$ ansible --version ansible [core 2.12.2] config file = /etc/ansible/ansible.cfg configured module search path = ['/home/sysadm/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.8/site-packages/ansible ansible collection location = /home/sysadm/.ansible/collections:/usr/share/ansible/collections executable location = /usr/bin/ansible python version = 3.8.12 (default, Jun 27 2023, 13:28:18) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)] jinja version = 2.10.3 libyaml = True
Thanks in advance for your comments.