linux-system-roles / network

An ansible role to configure networking
https://linux-system-roles.github.io/network/
BSD 3-Clause "New" or "Revised" License
237 stars 106 forks source link

not idempotent #689

Open emyr666 opened 6 months ago

emyr666 commented 6 months ago

It keeps saying...

TASK [network : Configure networking connection profiles] **********************
changed: [hostname]

...every time I run the playbook but nothing has changed.

This is the network role section. The template vars come from the host_vars files for each host.

    - role: network
      network_connections:
      - name: ens18
        type: ethernet
        autoconnect: true
        mac: "{{ pxe_mac }}"
        ip:
          dhcp4: true
      - name: ens19
        type: ethernet
        autoconnect: true
        mac: "{{ fast_mac }}"
        ip:
          dhcp4: false
          dhcp4: false
          gateway4: 10.21.0.253
          address:
          - "{{ fast_ip }}/16"
      - persistent_state: absent
emyr666 commented 6 months ago

Also, If I change the fast_ip variable and re run it I now get a routing table that looks like this...

[root@hostname]# ip route
default via 10.21.0.253 dev ens19 proto static metric 102
10.21.0.0/16 dev ens19 proto kernel scope link src 10.21.101.101 metric 102
10.21.0.0/16 dev ens19 proto kernel scope link src 10.21.100.1 metric 102
10.23.0.0/16 dev eth0 proto kernel scope link src 10.23.2.42 metric 101
127.0.0.0/8 dev lo proto kernel scope link src 127.0.0.1 metric 30

I.e the old ip still persists - the connection seems to have 2 ips yet the connection description says it should only have 1

spetrosi commented 6 months ago

Hi, thank you for reporting this. Please provide some info about your set up. What platforms you use as a control and managed Ansible nodes? From where do you run the role? Are you using the latest version?

emyr666 commented 6 months ago

hi, am using the latest version of this role. i use python3.10.8 with ansible installed via pip. The problem in my 2nd post was due to an oversight on my part. However the initial problem is still occurring. I.e. multiple invocations of ansible with this role when nothing changes always marks a change but this should not happen. It still shows

TASK [network : Configure networking connection profiles] **********************
changed: [hostname]

All the other subtasks of this role are fine and show no change. "network : Configure networking connection profiles" is the only one that constistently keeps logging a change in the absence of any change.

richm commented 4 months ago

@liangwen12year ^^^