nmcli fails to update DNS servers

168 views
Skip to first unread message

Anand Buddhdev

unread,
Mar 2, 2022, 5:53:16 AM3/2/22
to Ansible Project
I'm running ansible-core 2.12.3, on python 3.10, with 2 collections installed:

Collection        Version
----------------- -------
ansible.posix     1.3.0
community.general 4.5.0

I'm trying to use the nmcli module to set the DNS servers for a connection, and it's failing thus:

ansible HOST -m nmcli -a "conn_name=em1 type=ethernet state=present dns6='::1 2620:fe::fe'"
HOST | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "msg": "Error: Failed to modify connection 'em1': ipv4.gateway: gateway cannot be set if there are no addresses configured\n",
    "name": "em1",
    "rc": 1
}

I don't want/need to change the IP address settings, just the DNS. Any idea why nmcli is failing?

Regards,
Anand
Reply all
Reply to author
Forward
0 new messages