Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idempotence in the nmcli module with the 'route_metric4' parameter #4998

Open
1 task done
VolodymyrSerh opened this issue Jul 25, 2022 · 3 comments
Open
1 task done
Labels
bug This issue/PR relates to a bug has_pr module module net_tools plugins plugin (any type)

Comments

@VolodymyrSerh
Copy link

Summary

I figured out some Idempotence in the nmcli module with the 'route_metric4' parameter.
This issue is actual for both Ansible versions, 5.7 and 6.0.
By default, the route metric value is '-1'. You can verify this if you run the 'nmcli conn sh eth0' command, for example.

ipv4.route-metric: -1
ipv4.route-table: 0 (unspec)

If we have this value in our host vars and no one other network parameter changes, the playbook with nmcli task nothing change on the target system.
But only if we change any other network parameter 'route4', 'ipv6.method', doesn't matter, the 'route_metric4' parameter also will change from "-1" to -1.

  • "ipv4.route-metric": "-1",
  • "ipv4.route-metric": -1,

Of course, nothing has been changed on the target system finally, and 'nmcli conn sh' is showing the '-1' value as was before the playbook run.
It looks no so good.

Issue Type

Bug Report

Component Name

nmcli module

Ansible Version

$ ansible --version
ansible [core 2.12.7]
  config file = /home/user/git/ansible_configs/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.0.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 4.8.0  

Configuration

$ ansible-config dump --only-changed
DEFAULT_STRATEGY(/home/user/git/ansible_configs/ansible.cfg) = mitogen_linear
DEFAULT_STRATEGY_PLUGIN_PATH(/home/user/git/ansible_configs/ansible.cfg) = ['/home/user/git/ansible_configs/plugins/strategy/mitogen-0.3.2/ansible_mitogen/plugins/strategy']
HOST_KEY_CHECKING(/home/user/git/ansible_configs/ansible.cfg) = False
MAX_FILE_SIZE_FOR_DIFF(/home/user/git/ansible_configs/ansible.cfg) = 2097152
PERSISTENT_CONNECT_TIMEOUT(/home/user/git/ansible_configs/ansible.cfg) = 30

OS / Environment

Ubuntu 20.04

Steps to Reproduce

- name: Configure network interfaces via nmcli
  community.general.nmcli:
    conn_name: '{{ item.device }}'
    ifname: '{{ item.device }}'
    type: ethernet
    ip4: '{{ item.ip4 }}'
    gw4: '{{ item.gw }}'
    routes4: '{{ item.routes }}'
    method6: ignore
    route_metric4: '{{ item.metric }}'
    state: present
  tags:
    - 'network'
  with_items: '{{ facts_ifaces }}'

The route_metric4 by default have value '-1'
{
"msg": [
{
"device": "eth0",
"gw": null,
"ip4": "xx.xx.xx.xx/24",
"metric": -1,
"routes": []
}
]
}

Expected Results

I expected the route metric didn't changed if in host_vars and in real system it value were similar, '-1'
But when any other parameter will change for this interface the 'route_metric4' will change too.

Actual Results

--- before                                                                                                                                                                                                                      
+++ after                                                                                                                                                                                                                       
@@ -10,11 +10,12 @@                                                                                                                                                                                                             
     "ipv4.may-fail": "yes",                                                                                                                                                                                                    
     "ipv4.method": "manual",                                                                                                                                                                                                   
     "ipv4.never-default": "no",                                                                                                                                                                                                
-    "ipv4.route-metric": "-1",                                                                                                                                                                                                 
+    "ipv4.route-metric": -1,                                                                                                                                                                                                   
     "ipv4.routes": [                                                                                                                                                                                                                                                                                                                                                                                                     
     ],                                                                                                                                                                                                                         
     "ipv6.ignore-auto-dns": "no",                                                                                                                                                                                              
     "ipv6.ignore-auto-routes": "no",                                                                                                                                                                                           
-    "ipv6.method": "disabled"                                                                                                                                                                                                  
+    "ipv6.method": "ignore"                                                                                                                                                                                                    
 }                              

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

This was referenced Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module net_tools plugins plugin (any type)
Projects
None yet
Development

No branches or pull requests

2 participants