ansible-collections / cisco.ios

Ansible Network Collection for Cisco IOS
GNU General Public License v3.0
262 stars 161 forks source link

'merged' does not work when using cisco.ios.ios_route_maps #641

Closed netexgb closed 1 year ago

netexgb commented 1 year ago
SUMMARY

I have a route-map called TEST with only one entry, and I am trying to add another entry without replacing it. The route-map configuration is:

route-map TEST deny 10 description test deny match tag 999

After applying the change, I want it to look like:

route-map TEST deny 10 description test deny match tag 999 route-map TEST permit 65 description Allow prefixes from vendor match community vendor set as-path prepend 1 1 set community none

using merged, to no avail.

ISSUE TYPE
COMPONENT NAME

cisco.ios.ios_route_maps

ANSIBLE VERSION
ansible --version
ansible [core 2.13.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/xxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xxxx/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/xxxx/.ansible/collections
  executable location = /home/xxxx/.local/bin/ansible
  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
ansible-galaxy collection list cisco.ios

# /home/xxxx/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.ios  3.3.0

# /usr/local/lib/python3.8/dist-packages/ansible_collections
Collection Version
---------- -------
cisco.ios  3.3.0

# /home/xxxx/.local/lib/python3.8/site-packages/ansible_collections
Collection Version
---------- -------
cisco.ios  3.3.0
CONFIGURATION
ansible-config dump --only-changed
COLLECTIONS_PATHS(/etc/ansible/ansible.cfg) = ['/home/xxxx/.ansible/collections']
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = True
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = True
PARAMIKO_HOST_KEY_AUTO_ADD(/etc/ansible/ansible.cfg) = True
PARAMIKO_LOOK_FOR_KEYS(/etc/ansible/ansible.cfg) = True
RETRY_FILES_ENABLED(/etc/ansible/ansible.cfg) = False
TASK_TIMEOUT(/etc/ansible/ansible.cfg) = 0
STEPS TO REPRODUCE
---
- name: Route Map Check - DC Routers

  gather_facts: False
  vars:
    route_maps_xxxx_2:
      - parent: 'route-map TEST permit 65'
        lines:
          - 'description Allow prefixes from vendor'
          - 'match community vendor'
          - 'set as-path prepend 1 1'
          - 'set community none'

  tasks:
  - name: Applying Advertisement in Route Maps
    when: inventory_hostname == 'xxxx'
    cisco.ios.ios_route_maps:
      config:
        - route_map: TEST
          entries:
            - sequence: 65
              action: permit
              description: Allow prefixes from vendor
              match:
                community:
                  name: vendor
              set:
                as_path:
                  prepend:
                    as_number:
                      - 1
                      - 1
                community:
                  none: true
EXPECTED RESULTS
route-map TEST deny 10
 description test deny
 match tag 999
route-map TEST permit 65
 description Allow prefixes from vendor
 match community vendor
 set as-path prepend 1 1
 set community none
ACTUAL RESULTS
[xxxx@xxxx:/mnt/c/Users/xxxx/Repositories/xxxx/playbooks$ ansible-playbook xxxx-test2.yml -k -vvvv
ansible-playbook [core 2.13.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/xxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xxxx/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/xxxx/.ansible/collections
  executable location = /home/xxxx/.local/bin/ansible-playbook
  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
SSH password:
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with yaml plugin
Loading collection cisco.ios from /home/xxxx/.ansible/collections/ansible_collections/cisco/ios
redirecting (type: action) cisco.ios.ios_route_maps to cisco.ios.ios
Loading callback plugin default of type stdout, v2.0 from /home/xxxx/.local/lib/python3.8/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: xxxx-test2.yml **********************************************************************************************************************************************************************************************************************************Positional arguments: xxxx-test2.yml
verbosity: 4
connection: smart
timeout: 10
ask_pass: True
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in xxxx-test2.yml

PLAY [Route Map Check - DC Routers] ******************************************************************************************************************************************************************************************************************META: ran handlers
redirecting (type: action) cisco.ios.ios_route_maps to cisco.ios.ios
Loading collection ansible.netcommon from /home/xxxx/.ansible/collections/ansible_collections/ansible/netcommon

TASK [Applying Advertisement in Route Maps - xxxx_2] ******************************************************************************************************************************************************************************************************task path: /mnt/c/Users/xxxxx/Repositories/xxxx/playbooks/xxxx-test2.yml:16
redirecting (type: action) cisco.ios.ios_route_maps to cisco.ios.ios
skipping: [xxxxx] => {
    "changed": false,
    "skip_reason": "Conditional result was False"
}
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<xxxx> attempting to start connection
<xxxx> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/xxxx/.local/bin/ansible-connection
<xxxx> local domain socket does not exist, starting it
<xxxx> control socket path is /home/xxxx/.ansible/pc/5d37493492
<xxxx> Loading collection ansible.netcommon from /home/xxxx/.ansible/collections/ansible_collections/ansible/netcommon
<xxxx> redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
<xxxx> Loading collection cisco.ios from /home/xxxx/.ansible/collections/ansible_collections/cisco/ios
<xxxx> redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<xxxx> local domain socket listeners started successfully
<xxxx> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/xxxx/.ansible/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os ios
<xxxx> ssh type is set to auto
<xxxx> autodetecting ssh_type
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
<xxxx> ssh type is now set to paramiko
<xxxx>
<xxxx> local domain socket path is /home/xxxx/.ansible/pc/5d37493492
redirecting (type: action) cisco.ios.ios_route_maps to cisco.ios.ios
redirecting (type: action) cisco.ios.ios_route_maps to cisco.ios.ios
<xxxx> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<xxxx> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_route_maps  at /home/xxxx/.ansible/collections/ansible_collections/cisco/ios/plugins/modules/ios_route_maps.py
<xxxx> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_route_maps
<xxxxt> ANSIBLE_NETWORK_IMPORT_MODULES: complete

META: ran handlers
META: ran handlers

PLAY RECAP **************************************************************************************************************************************************************************************************************************************************xxxx : ok=0    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
xxxx : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
netexgb commented 1 year ago

@bentole ... checking on this fix, I also tried to use 'replaced' to add a new route-map entry to no avail. Will this require a new bug request as well?