# Nmcli changes not persistent in rhel 8.6

**URL:** <https://forum.ansible.com/t/nmcli-changes-not-persistent-in-rhel-8-6/1064>\
**Category:** Get Help\
**Tags:** rhel, dns, playbook, linux-system-roles, ansible-core\
**Created:** [September 23, 2023, 5:56pm UTC](https://forum.ansible.com/t/nmcli-changes-not-persistent-in-rhel-8-6/1064 "2023-09-23T17:56:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ErickPH](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/erickph/32/799_2.png) [@ErickPH](https://forum.ansible.com/u/ErickPH)\
**Post date:** [September 23, 2023, 5:56pm UTC](https://forum.ansible.com/t/nmcli-changes-not-persistent-in-rhel-8-6/1064/1 "2023-09-23T17:56:49Z")

</div>

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?

```auto
- 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.

```auto
$ 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.

---

<div class="post-metadata">

**Author:** ![jbericat](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jbericat/32/627_2.png) [@jbericat](https://forum.ansible.com/u/jbericat)\
**Post date:** [September 24, 2023, 5:19am UTC](https://forum.ansible.com/t/nmcli-changes-not-persistent-in-rhel-8-6/1064/2 "2023-09-24T05:19:00Z")

</div>

Hello @ErickPH,

Check this link out:

> **[Configuring and managing networking | Red Hat Product Documentation](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html-single/configuring_and_managing_networking/index)**
>
> Configuring and managing networking | Red Hat Documentation

In **Section 2 - Configuring an Ethernet Connection** there is this notice:

 ![image](https://us1.discourse-cdn.com/ansible/original/1X/847e4733478a6451f2fe0b2c8d9ac38dda3d6b03.png)

Could this be the root of your issue?

Cheers!

---

<div class="post-metadata">

**Author:** ![Leo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/leo/32/23_2.png) [@Leo](https://forum.ansible.com/u/Leo)\
**Post date:** [September 25, 2023, 8:33pm UTC](https://forum.ansible.com/t/nmcli-changes-not-persistent-in-rhel-8-6/1064/3 "2023-09-25T20:33:34Z")

</div>

Hi @ErickPH , welcome to the Ansible community forum!

Adding to the great catch by @jbericat , you might also want to check out the [Ansible RHEL System Roles](https://access.redhat.com/articles/3050101) (or [upstream Linux System Roles](https://linux-system-roles.github.io/) for those without RHEL subscriptions) for configuration management of all the RHEL subsystems.

Have a look at the specific system role for networking for example:

> **[Chapter 20. Configuring network settings by using...](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/automating_system_administration_by_using_rhel_system_roles/assembly_configuring-network-settings-by-using-rhel-system-roles_automating-system-administration-by-using-rhel-system-roles)**
>
> Chapter 20. Configuring network settings by using RHEL system roles | Red Hat Documentation

---

<div class="post-metadata">

**Author:** ![jbericat](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jbericat/32/627_2.png) [@jbericat](https://forum.ansible.com/u/jbericat)\
**Post date:** [September 26, 2023, 4:27am UTC](https://forum.ansible.com/t/nmcli-changes-not-persistent-in-rhel-8-6/1064/4 "2023-09-26T04:27:34Z")

</div>

> [@Leo](#):
>
> (or [upstream Linux System Roles](https://linux-system-roles.github.io/) for those without RHEL subscriptions)

That’s a good one too @Leo !

Cheers

---

<div class="post-metadata">

**Author:** ![gwmngilfen](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gwmngilfen/32/6_2.png) [@gwmngilfen](https://forum.ansible.com/u/gwmngilfen)\
**Post date:** [October 6, 2023, 8:51am UTC](https://forum.ansible.com/t/nmcli-changes-not-persistent-in-rhel-8-6/1064/5 "2023-10-06T08:51:54Z")

</div>

Hi @ErickPH! It looks like the post might be solved - could you check to see if the response by @jbericat or @leo worked for you?

If so, it would be _super_ helpful if you could click the ✔ on their post to accept the solution - it recognises the input of others, helps our volunteers find new issues to answer, and keeps the forum nice and tidy.

Thanks!  
(this is template reply, do feel free to reply if I’ve misunderstood the situation!)
