ansible-collections / arista.eos

Ansible Network Collection for Arista EOS
GNU General Public License v3.0
81 stars 64 forks source link

"eos_lag_interfaces" idempotency is not working correctly #515

Closed ivanchakarov closed 3 months ago

ivanchakarov commented 4 months ago
SUMMARY

I'm trying to create a playbook which should configure a LAG on a switch port and then should control whether the switches configuration is matching the desired one in the playbook.

ISSUE TYPE
COMPONENT NAME

eos_lag_interfaces

ANSIBLE VERSION
ansible [core 2.15.8]
  config file = /home/ichakarov/Ansible/ansible_tutorial/ansible.cfg
  configured module search path = ['/home/ichakarov/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/ichakarov/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
Collection                    Version
----------------------------- -------
ansible.netcommon             6.0.0  
ansible.utils                 3.0.0  
arista.eos                    7.0.0  
CONFIGURATION
CONFIG_FILE() = /home/ichakarov/Ansible/ansible_tutorial/ansible.cfg
DEFAULT_GATHERING(/home/ichakarov/Ansible/ansible_tutorial/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/home/ichakarov/Ansible/ansible_tutorial/ansible.cfg) = ['/home/ichakarov/Ansible/ansible_tutorial/inventory.yaml']
HOST_KEY_CHECKING(/home/ichakarov/Ansible/ansible_tutorial/ansible.cfg) = False
OS / ENVIRONMENT
Arista vEOS-lab
Software image version: 4.31.1F
STEPS TO REPRODUCE

Execute the following simple palybook two times:

---
- name: Test play
  hosts: vbox-switch

  tasks:
    - name: Configuring the LAG ports
      arista.eos.eos_lag_interfaces:
        config:
          - name: 6
            members:
              - member: Ethernet3
                mode: active
EXPECTED RESULTS

The first run always completes as expected. The command "channel-group 6 mode active" is applied to interface Ethernet3. The expectation is that when we run the same playbook again, Ansible should report that no changes have to be applied.

ACTUAL RESULTS

Unfortunately, on the second run (and every following) Ansible reports that it needs to apply the same command again. As you can see the "before" and "after" states are identical but "changed" is "true".

TASK [Configuring the LAG ports] ******************************************************************************************************************************************************************************************
task path: /home/ichakarov/Ansible/ansible_test/temp-play.yaml:6
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
changed: [vbox-switch] => {
    "after": [
        {
            "members": [
                {
                    "member": "Ethernet3",
                    "mode": "active"
                }
            ],
            "name": "Port-Channel6"
        }
    ],
    "before": [
        {
            "members": [
                {
                    "member": "Ethernet3",
                    "mode": "active"
                }
            ],
            "name": "Port-Channel6"
        }
    ],
    "changed": true,
    "commands": [
        "interface Ethernet3",
        "channel-group 6 mode active"
    ],
    "invocation": {
        "module_args": {
            "config": [
                {
                    "members": [
                        {
                            "member": "Ethernet3",
                            "mode": "active"
                        }
                    ],
                    "name": "6"
                }
            ],
            "running_config": null,
            "state": "merged"
        }
    }
}

PLAY RECAP ****************************************************************************************************************************************************************************************************************
vbox-switch                : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
roverflow commented 4 months ago

Hey @ivanchakarov , The issue is actually caused due the name attribute being just a number. The name attribute value should be either a shorthand like po6 or full string Port-Channel6.

For example:

---
- name: Test play
  hosts: vbox-switch

  tasks:
    - name: Configuring the LAG ports
      arista.eos.eos_lag_interfaces:
        config:
          - name: po6    # or Port-Channel6
            members:
              - member: Ethernet3
                mode: active

This will be idempotent.

A documentation update is incoming and will be updated.

ivanchakarov commented 4 months ago

Thank you!