ansible-collections / cisco.ios

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

Interface description values such as 5j evaluated as complex, cast to string #1017

Closed gellis713 closed 1 month ago

gellis713 commented 3 months ago
SUMMARY

Fixes #829

829 details a scenario where interface descriptions such as:

5j 05j 1j 25j 125j 19J 82J

causes the Python JSON encoder to throw an error stating "Object of type complex is not JSON serializable". After some digging this complex data type is being returned from the Template class in Ansible Netcommon Utils

    def __call__(self, value, variables=None, fail_on_undefined=True):
        variables = variables or {}

        if not self.contains_vars(value):
            return value

        try:
            value = self.env.from_string(value).render(variables)
        except UndefinedError:
            if not fail_on_undefined:
                return None
            raise

        if value:
            try:
                return ast.literal_eval(value)
            except Exception:
                return str(value)
        else:
            return None

The call function renders the data into "value" and tries to use ast to perform an evaluation of a literal structure. Most literal_evals will throw an error (such as ValueError: malformed node or string on line 1: <ast.Name object at 0x7f1302b682b0> which is caught and the value is casted into a string. Since "5j" and variants are actually evaluated into complex data type, it just gets passed back as is.

ISSUE TYPE
COMPONENT NAME

cisco_ios.ios.ios_interfaces Module

ADDITIONAL INFORMATION

Tested on Cisco 2960X, Version 15.0(2)EX4

griffin@griffin-laptop:~/Documents/code/ansible-modules$ ansible-playbook cisco_description_parse.playbook -vvvv
ansible-playbook 2.10.8
  config file = None
  configured module search path = ['/home/griffin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
No config file found; using defaults
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
Not replacing invalid character(s) "{'-'}" in group name (ios-switches)
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
Not replacing invalid character(s) "{'-'}" in group name (ios-switches)
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading collection cisco.ios from /home/griffin/.ansible/collections/ansible_collections/cisco/ios
[WARNING]: Collection cisco.ios does not support Ansible version 2.10.8
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3/dist-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: cisco_description_parse.playbook ****************************************************************************************************************************************************************************************************************************************
Positional arguments: cisco_description_parse.playbook
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in cisco_description_parse.playbook

PLAY [Gather listed interfaces] ***************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [Interface status] ***********************************************************************************************************************************************************************************************************************************************************
task path: /home/griffin/Documents/code/ansible-modules/cisco_description_parse.playbook:7
Loading collection ansible.netcommon from /home/griffin/.ansible/collections/ansible_collections/ansible/netcommon
[WARNING]: Collection ansible.netcommon does not support Ansible version 2.10.8
Loading collection ansible.utils from /home/griffin/.ansible/collections/ansible_collections/ansible/utils
[WARNING]: Collection ansible.utils does not support Ansible version 2.10.8
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<192.168.1.5> attempting to start connection
<192.168.1.5> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/bin/ansible-connection
<192.168.1.5> local domain socket does not exist, starting it
<192.168.1.5> control socket path is /home/griffin/.ansible/pc/5d51325db8
<192.168.1.5> Loading collection ansible.netcommon from /home/griffin/.ansible/collections/ansible_collections/ansible/netcommon
<192.168.1.5> Loading collection ansible.utils from /home/griffin/.ansible/collections/ansible_collections/ansible/utils
<192.168.1.5> Loading collection cisco.ios from /home/griffin/.ansible/collections/ansible_collections/cisco/ios
<192.168.1.5> local domain socket listeners started successfully
<192.168.1.5> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios
<192.168.1.5> ssh type is set to auto
<192.168.1.5> autodetecting ssh_type
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
<192.168.1.5> ssh type is now set to paramiko
<192.168.1.5> 
<192.168.1.5> local domain socket path is /home/griffin/.ansible/pc/5d51325db8
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_interfaces  at /home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/modules/ios_interfaces.py
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_interfaces
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: complete
The full traceback is:
  File "/home/griffin/.ansible/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py", line 128, in get_network_resources_facts
    inst.populate_facts(self._connection, self.ansible_facts, data)
  File "/home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/module_utils/network/ios/facts/interfaces/interfaces.py", line 60, in populate_facts
    interfaces_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),
  File "/home/griffin/.ansible/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/rm_base/network_template.py", line 139, in validate_config
    validated_data = _validate_config(spec, data)
  File "/home/griffin/.ansible/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py", line 621, in validate_config
    basic._ANSIBLE_ARGS = to_bytes(json.dumps({"ANSIBLE_MODULE_ARGS": data}))
  File "/usr/lib/python3.10/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
fatal: [192.168.1.5]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "config": null,
            "running_config": null,
            "state": "gathered"
        }
    },
    "msg": "Object of type complex is not JSON serializable"
}

PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************************
192.168.1.5                : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

After change (5j value that previously evaluated to complex):

griffin@griffin-laptop:~/Documents/code/ansible-modules$ ansible-playbook cisco_description_parse.playbook -vvvv
ansible-playbook 2.10.8
  config file = None
  configured module search path = ['/home/griffin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
No config file found; using defaults
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
Not replacing invalid character(s) "{'-'}" in group name (ios-switches)
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
Not replacing invalid character(s) "{'-'}" in group name (ios-switches)
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading collection cisco.ios from /home/griffin/.ansible/collections/ansible_collections/cisco/ios
[WARNING]: Collection cisco.ios does not support Ansible version 2.10.8
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3/dist-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: cisco_description_parse.playbook ****************************************************************************************************************************************************************************************************************************************
Positional arguments: cisco_description_parse.playbook
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in cisco_description_parse.playbook

PLAY [Gather listed interfaces] ***************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [Interface status] ***********************************************************************************************************************************************************************************************************************************************************
task path: /home/griffin/Documents/code/ansible-modules/cisco_description_parse.playbook:7
Loading collection ansible.netcommon from /home/griffin/.ansible/collections/ansible_collections/ansible/netcommon
[WARNING]: Collection ansible.netcommon does not support Ansible version 2.10.8
Loading collection ansible.utils from /home/griffin/.ansible/collections/ansible_collections/ansible/utils
[WARNING]: Collection ansible.utils does not support Ansible version 2.10.8
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<192.168.1.5> attempting to start connection
<192.168.1.5> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/bin/ansible-connection
<192.168.1.5> local domain socket does not exist, starting it
<192.168.1.5> control socket path is /home/griffin/.ansible/pc/5ee9317108
<192.168.1.5> Loading collection ansible.netcommon from /home/griffin/.ansible/collections/ansible_collections/ansible/netcommon
<192.168.1.5> Loading collection ansible.utils from /home/griffin/.ansible/collections/ansible_collections/ansible/utils
<192.168.1.5> Loading collection cisco.ios from /home/griffin/.ansible/collections/ansible_collections/cisco/ios
<192.168.1.5> local domain socket listeners started successfully
<192.168.1.5> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios
<192.168.1.5> ssh type is set to auto
<192.168.1.5> autodetecting ssh_type
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
<192.168.1.5> ssh type is now set to paramiko
<192.168.1.5> 
<192.168.1.5> local domain socket path is /home/griffin/.ansible/pc/5ee9317108
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_interfaces  at /home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/modules/ios_interfaces.py
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_interfaces
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: complete
ok: [192.168.1.5] => {
    "changed": false,
    "gathered": [
        {
            "description": "5j",
            "enabled": true,
            "name": "FastEthernet0"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/1"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/10"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/11"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/12"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/13"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/14"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/15"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/16"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/17"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/18"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/19"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/2"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/20"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/21"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/22"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/23"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/24"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/25"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/26"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/27"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/28"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/29"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/3"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/30"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/31"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/32"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/33"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/34"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/35"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/36"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/37"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/38"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/39"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/4"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/40"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/41"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/42"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/43"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/44"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/45"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/46"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/47"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/48"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/49"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/5"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/50"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/51"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/52"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/6"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/7"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/8"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/9"
        },
        {
            "enabled": true,
            "name": "Vlan1"
        }
    ],
    "invocation": {
        "module_args": {
            "config": null,
            "running_config": null,
            "state": "gathered"
        }
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************************
192.168.1.5                : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

After change (typical description format):

griffin@griffin-laptop:~/Documents/code/ansible-modules$ ansible-playbook cisco_description_parse.playbook -vvvv
ansible-playbook 2.10.8
  config file = None
  configured module search path = ['/home/griffin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
No config file found; using defaults
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
Not replacing invalid character(s) "{'-'}" in group name (ios-switches)
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
Not replacing invalid character(s) "{'-'}" in group name (ios-switches)
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading collection cisco.ios from /home/griffin/.ansible/collections/ansible_collections/cisco/ios
[WARNING]: Collection cisco.ios does not support Ansible version 2.10.8
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3/dist-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: cisco_description_parse.playbook ****************************************************************************************************************************************************************************************************************************************
Positional arguments: cisco_description_parse.playbook
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in cisco_description_parse.playbook

PLAY [Gather listed interfaces] ***************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [Interface status] ***********************************************************************************************************************************************************************************************************************************************************
task path: /home/griffin/Documents/code/ansible-modules/cisco_description_parse.playbook:7
Loading collection ansible.netcommon from /home/griffin/.ansible/collections/ansible_collections/ansible/netcommon
[WARNING]: Collection ansible.netcommon does not support Ansible version 2.10.8
Loading collection ansible.utils from /home/griffin/.ansible/collections/ansible_collections/ansible/utils
[WARNING]: Collection ansible.utils does not support Ansible version 2.10.8
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<192.168.1.5> attempting to start connection
<192.168.1.5> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/bin/ansible-connection
<192.168.1.5> local domain socket does not exist, starting it
<192.168.1.5> control socket path is /home/griffin/.ansible/pc/2f9ab2771c
<192.168.1.5> Loading collection ansible.netcommon from /home/griffin/.ansible/collections/ansible_collections/ansible/netcommon
<192.168.1.5> Loading collection ansible.utils from /home/griffin/.ansible/collections/ansible_collections/ansible/utils
<192.168.1.5> Loading collection cisco.ios from /home/griffin/.ansible/collections/ansible_collections/cisco/ios
<192.168.1.5> local domain socket listeners started successfully
<192.168.1.5> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios
<192.168.1.5> ssh type is set to auto
<192.168.1.5> autodetecting ssh_type
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
<192.168.1.5> ssh type is now set to paramiko
<192.168.1.5> 
<192.168.1.5> local domain socket path is /home/griffin/.ansible/pc/2f9ab2771c
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_interfaces  at /home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/modules/ios_interfaces.py
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_interfaces
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: complete
ok: [192.168.1.5] => {
    "changed": false,
    "gathered": [
        {
            "description": "this is a test",
            "enabled": true,
            "name": "FastEthernet0"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/1"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/10"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/11"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/12"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/13"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/14"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/15"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/16"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/17"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/18"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/19"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/2"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/20"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/21"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/22"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/23"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/24"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/25"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/26"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/27"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/28"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/29"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/3"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/30"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/31"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/32"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/33"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/34"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/35"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/36"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/37"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/38"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/39"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/4"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/40"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/41"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/42"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/43"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/44"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/45"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/46"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/47"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/48"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/49"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/5"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/50"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/51"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/52"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/6"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/7"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/8"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/9"
        },
        {
            "enabled": true,
            "name": "Vlan1"
        }
    ],
    "invocation": {
        "module_args": {
            "config": null,
            "running_config": null,
            "state": "gathered"
        }
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************************
192.168.1.5                : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
softwarefactory-project-zuul[bot] commented 3 months ago

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/02888a3d65694bc3a9c58ba8d45eb160

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 3m 29s :heavy_check_mark: build-ansible-collection SUCCESS in 11m 32s :x: ansible-ee-integration-ios-latest RETRY_LIMIT in 3m 25s (non-voting) :x: ansible-ee-integration-ios-stable-2.9 FAILURE in 12m 17s (non-voting) :x: ansible-ee-integration-ios-stable-2.11 RETRY_LIMIT in 3m 11s (non-voting) :x: ansible-ee-integration-ios-stable-2.12 RETRY_LIMIT in 3m 11s (non-voting) :x: ansible-ee-integration-ios-libssh-latest RETRY_LIMIT in 3m 29s (non-voting) :x: ansible-ee-integration-ios-libssh-stable-2.9 FAILURE in 13m 33s (non-voting) :x: ansible-ee-integration-ios-libssh-stable-2.11 RETRY_LIMIT in 3m 21s (non-voting) :x: ansible-ee-integration-ios-libssh-stable-2.12 RETRY_LIMIT in 23m 01s (non-voting) :heavy_check_mark: ansible-tox-linters SUCCESS in 13m 21s

gellis713 commented 3 months ago

Additional successful manual testing done against the 2960X to set interface descriptions:

griffin@griffin-laptop:~/Documents/code/ansible-modules$ ansible-playbook cisco_description_set.playbook -vvvv
ansible-playbook 2.10.8
  config file = None
  configured module search path = ['/home/griffin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
No config file found; using defaults
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
Not replacing invalid character(s) "{'-'}" in group name (ios-switches)
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
Not replacing invalid character(s) "{'-'}" in group name (ios-switches)
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading collection cisco.ios from /home/griffin/.ansible/collections/ansible_collections/cisco/ios
[WARNING]: Collection cisco.ios does not support Ansible version 2.10.8
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3/dist-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: cisco_description_set.playbook ******************************************************************************************************************************************************************************************************************************************
Positional arguments: cisco_description_set.playbook
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in cisco_description_set.playbook

PLAY [Set interface description] **************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [Interface status] ***********************************************************************************************************************************************************************************************************************************************************
task path: /home/griffin/Documents/code/ansible-modules/cisco_description_set.playbook:7
Loading collection ansible.netcommon from /home/griffin/.ansible/collections/ansible_collections/ansible/netcommon
[WARNING]: Collection ansible.netcommon does not support Ansible version 2.10.8
Loading collection ansible.utils from /home/griffin/.ansible/collections/ansible_collections/ansible/utils
[WARNING]: Collection ansible.utils does not support Ansible version 2.10.8
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<192.168.1.5> attempting to start connection
<192.168.1.5> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/bin/ansible-connection
<192.168.1.5> local domain socket does not exist, starting it
<192.168.1.5> control socket path is /home/griffin/.ansible/pc/1736253856
<192.168.1.5> Loading collection ansible.netcommon from /home/griffin/.ansible/collections/ansible_collections/ansible/netcommon
<192.168.1.5> Loading collection ansible.utils from /home/griffin/.ansible/collections/ansible_collections/ansible/utils
<192.168.1.5> Loading collection cisco.ios from /home/griffin/.ansible/collections/ansible_collections/cisco/ios
<192.168.1.5> local domain socket listeners started successfully
<192.168.1.5> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios
<192.168.1.5> ssh type is set to auto
<192.168.1.5> autodetecting ssh_type
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
<192.168.1.5> ssh type is now set to paramiko
<192.168.1.5> 
<192.168.1.5> local domain socket path is /home/griffin/.ansible/pc/1736253856
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_interfaces  at /home/griffin/.ansible/collections/ansible_collections/cisco/ios/plugins/modules/ios_interfaces.py
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_interfaces
<192.168.1.5> ANSIBLE_NETWORK_IMPORT_MODULES: complete
changed: [192.168.1.5] => {
    "after": [
        {
            "description": "5j",
            "enabled": true,
            "name": "FastEthernet0"
        },
        {
            "description": "5j",
            "enabled": true,
            "name": "GigabitEthernet1/0/1"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/10"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/11"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/12"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/13"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/14"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/15"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/16"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/17"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/18"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/19"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/2"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/20"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/21"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/22"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/23"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/24"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/25"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/26"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/27"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/28"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/29"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/3"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/30"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/31"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/32"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/33"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/34"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/35"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/36"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/37"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/38"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/39"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/4"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/40"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/41"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/42"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/43"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/44"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/45"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/46"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/47"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/48"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/49"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/5"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/50"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/51"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/52"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/6"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/7"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/8"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/9"
        },
        {
            "enabled": true,
            "name": "Vlan1"
        }
    ],
    "before": [
        {
            "description": "5j",
            "enabled": true,
            "name": "FastEthernet0"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/1"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/10"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/11"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/12"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/13"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/14"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/15"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/16"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/17"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/18"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/19"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/2"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/20"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/21"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/22"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/23"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/24"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/25"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/26"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/27"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/28"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/29"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/3"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/30"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/31"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/32"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/33"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/34"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/35"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/36"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/37"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/38"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/39"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/4"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/40"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/41"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/42"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/43"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/44"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/45"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/46"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/47"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/48"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/49"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/5"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/50"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/51"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/52"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/6"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/7"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/8"
        },
        {
            "enabled": true,
            "name": "GigabitEthernet1/0/9"
        },
        {
            "enabled": true,
            "name": "Vlan1"
        }
    ],
    "changed": true,
    "commands": [
        "interface GigabitEthernet1/0/1",
        "description 5j"
    ],
    "invocation": {
        "module_args": {
            "config": [
                {
                    "description": "5j",
                    "duplex": null,
                    "enabled": true,
                    "mode": null,
                    "mtu": null,
                    "name": "GigabitEthernet1/0/1",
                    "speed": null,
                    "template": null
                }
            ],
            "running_config": null,
            "state": "replaced"
        }
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************************
192.168.1.5                : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.93%. Comparing base (cd326fe) to head (9a3f095).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1017 +/- ## ======================================= Coverage 86.93% 86.93% ======================================= Files 195 195 Lines 12102 12102 ======================================= Hits 10521 10521 Misses 1581 1581 ``` [see 2 files with indirect coverage changes](https://app.codecov.io/gh/ansible-collections/cisco.ios/pull/1017/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ansible-collections)
KB-perByte commented 1 month ago

@gellis713 Thank you for the contribution, I have pushed some additional changes considering your solution. Regards.