Nmcli ansible module

Hi,
Anyone used nmcli ansible module to configure Ethernet Interface in a Virtual Machine. Simple task to enable Ethernet interface is not getting interface to Active. We manually need to UP the interface to update the configurations like IPv4 address, GW etc.

Disabling seems working fine.

autoconnect=yes? Or NM restart in handler?

Tell the truth, I haven’t dared to config network with ansible yet. Feels like sawing a branch while sitting on it.

Tried with “autoconnect”: true and above scenario noticed.

Also trying to see how nmcli ansible modules can be used policy routing to Rocky VM’s.
Eg: like use of routing_rules4

We could able to update rules for single entries as,
routing_rules4: “priority 0 from {{ item.ip4 | ipaddr(‘address’) }} lookup {{ item.route_table }}”

But when we tried add one one entry it’s not working.

Anyone tried adding multiple rules similar to this

As said, I haven’t used ansible to do network. Not much policy routing either.
Besides, I use ansible 2.9. routing_rules4 is not in it.

There is package to enable legacy rule format:

Name         : NetworkManager-dispatcher-routing-rules
Description  : This adds a NetworkManager dispatcher file to support networking
             : configurations using "/etc/sysconfig/network-scripts/rule-NAME" files
             : (eg, to do policy-based routing).

That obviously works around the lacking “native support” of nmcli.

Chapter 22. Configuring policy-based routing to define alternative routes Red Hat Enterprise Linux 8 | Red Hat Customer Portal says:
“Note that the syntax in the ipv4.routing-rules parameter is the same as in an ip route add command, except that ipv4.routing-rules always requires specifying a priority.”
which makes no sense as it should invoke equivalent of ip rule add (unless ‘rule add’ and ‘route add’ use same syntax).

In man nm-settings the ipv4.routing-rules is undocumented.

You can create the legacy rules with Ansible.

Yes. I think for policy based routing as you mentioned using legacy rules could be good at this point of time. For common configurations nmcli works fine.

Thanks for the information