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

ios_l3_interfaces is not able to remove primary ipv4 address #826

Closed
matejv opened this issue May 17, 2023 · 0 comments · Fixed by #827
Closed

ios_l3_interfaces is not able to remove primary ipv4 address #826

matejv opened this issue May 17, 2023 · 0 comments · Fixed by #827

Comments

@matejv
Copy link
Contributor

matejv commented May 17, 2023

SUMMARY

When you have multiple IPv4 addresses on an interface and you want to remove the one that is primary (promoting one of current secondary addresses to primary), the module does not complete this action successfully but does not report any errors. This happens because Cisco IOS does not allow removing a primary address when there are secondary addresses on the interface.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.ios.ios_l3_interfaces

ANSIBLE VERSION
ansible [core 2.12.5]
  config file = /home/matej/Projects/harfa/ansible.cfg
  configured module search path = ['/home/matej/.pyenv/versions/3.10.1/envs/harfa/lib/python3.10/site-packages/napalm_ansible/modules']
  ansible python module location = /home/matej/.pyenv/versions/3.10.1/envs/harfa/lib/python3.10/site-packages/ansible
  ansible collection location = /home/matej/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/matej/.pyenv/versions/harfa/bin/ansible
  python version = 3.10.1 (main, Dec 25 2021, 09:38:16) [GCC 11.2.0]
  jinja version = 3.1.2
  libyaml = True

COLLECTION VERSION
# /home/matej/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.ios  4.5.0 
CONFIGURATION
ANSIBLE_NOCOWS(/home/matej/Projects/harfa/ansible.cfg) = True
DEFAULT_ACTION_PLUGIN_PATH(env: ANSIBLE_ACTION_PLUGINS) = ['/home/matej/.pyenv/versions/3.10.1/envs/harfa/lib/python3.10/site-packages/napalm_ansible/plugins/action']
DEFAULT_HOST_LIST(/home/matej/Projects/harfa/ansible.cfg) = ['/home/matej/Projects/harfa/inventories/testing/hosts']
DEFAULT_INVENTORY_PLUGIN_PATH(/home/matej/Projects/harfa/ansible.cfg) = ['/home/matej/Projects/harfa/inventory_plugins']
DEFAULT_MANAGED_STR(/home/matej/Projects/harfa/ansible.cfg) = This file is managed by ansible project anso/harfa. Do not edit by hand.
DEFAULT_MODULE_PATH(env: ANSIBLE_LIBRARY) = ['/home/matej/.pyenv/versions/3.10.1/envs/harfa/lib/python3.10/site-packages/napalm_ansible/modules']
DEFAULT_MODULE_UTILS_PATH(/home/matej/Projects/harfa/ansible.cfg) = ['/home/matej/Projects/harfa/module_utils']
DEFAULT_STDOUT_CALLBACK(/home/matej/Projects/harfa/ansible.cfg) = community.general.yaml
HOST_KEY_CHECKING(/home/matej/Projects/harfa/ansible.cfg) = False
INVENTORY_ENABLED(/home/matej/Projects/harfa/ansible.cfg) = ['host_list', 'ini', 'yaml', 'constructed']
PERSISTENT_COMMAND_TIMEOUT(/home/matej/Projects/harfa/ansible.cfg) = 60
PERSISTENT_CONNECT_TIMEOUT(/home/matej/Projects/harfa/ansible.cfg) = 60
RETRY_FILES_ENABLED(/home/matej/Projects/harfa/ansible.cfg) = True
RETRY_FILES_SAVE_PATH(/home/matej/Projects/harfa/ansible.cfg) = /home/matej/Projects/harfa/ansible_retry
SHOW_CUSTOM_STATS(/home/matej/Projects/harfa/ansible.cfg) = True
TRANSFORM_INVALID_GROUP_CHARS(/home/matej/Projects/harfa/ansible.cfg) = ignore
OS / ENVIRONMENT

Controller node: Ubuntu 22.04
Managed network device: Cisco C9500-48Y4C, IOS XE Version 17.7.1 (other models and versions also affected, possibly all IOS)

STEPS TO REPRODUCE

Start with this configuration on router:

#sh run int Vlan111
Building configuration...

Current configuration : 106 bytes
!
interface Vlan111
 ip address 10.0.22.1 255.255.255.0 secondary
 ip address 10.0.1.1 255.255.255.0
end

Run the following playbook:

- name: test ios l3 interfaces
  hosts: myrouter
  tasks:
    - name: update addresses
      cisco.ios.ios_l3_interfaces:
        config:
          - name: Vlan111
            ipv4:
              - address: 10.0.22.1/24
                secondary: false
        state: replaced
EXPECTED RESULTS

Expected router config:

interface Vlan111
 ip address 10.0.22.1 255.255.255.0
end
ACTUAL RESULTS

Verbose output from task:

TASK [update addresses] **************************************************************************************************
changed: [myrouter] => changed=true 
  before:
  - ipv4:
    - address: 10.0.22.1/24
      secondary: true
    - address: 10.0.1.1/24
    name: Vlan111
  after:
  - ipv4:
    - address: 10.0.22.1/24
      secondary: true
    - address: 10.0.1.1/24
    name: Vlan111
  commands:
  - interface Vlan111
  - no ip address 10.0.1.1 255.255.255.0

Actual config on router:

interface Vlan111
 ip address 10.0.22.1 255.255.255.0 secondary
 ip address 10.0.1.1 255.255.255.0
end

If you try to run commands that module generates manually you get an error and command is rejected:

myrouter#sh run int Vlan111
Building configuration...

Current configuration : 106 bytes
!
interface Vlan111
 ip address 10.0.22.1 255.255.255.0 secondary
 ip address 10.0.1.1 255.255.255.0
end

myrouter#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
myrouter(config)#interface Vlan111
myrouter(config-if)#no ip address 10.0.1.1 255.255.255.0
Must delete secondary before deleting primary
myrouter(config-if)#end
myrouter#sh run int Vlan111
Building configuration...

Current configuration : 106 bytes
!
interface Vlan111
 ip address 10.0.22.1 255.255.255.0 secondary
 ip address 10.0.1.1 255.255.255.0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant