ansible-collections / cisco.ios

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

ios_facts and ios_service not showing correct state of services #1016

Closed cfergs closed 3 months ago

cfergs commented 3 months ago
SUMMARY

I am running IOS 15.2(7)E9. I notice when running ios_facts and ios_service it doesn't show the correct state of certain services. I have previously disabled dhcp, slave_log and enabled config:

For example from ios_facts

"ansible_network_resources": {
  "service": {
      "config": true,
      "counters": 0,
      "dhcp": true,
      "password_recovery": true,
      "prompt": true,
      "slave_log": true
  }
}

But when i run show running-config all | section ^service on the switch it shows dhcp and slave_log as disabled:

service config
service prompt config
service counters max age 0

My running config on the switch:

version 15.2
service config
no service slave-log
no service pad
no service timestamps debug uptime
no service timestamps log uptime
no service password-encryption
no service dhcp
!

This also affects the ios_service component as it is unable to accurately determine the correct state of some services

ISSUE TYPE
COMPONENT NAME

cisco.ios.ios_facts, cisco.ios.ios_service

ANSIBLE VERSION
ansible [core 2.16.1]
  config file = /home/colin/Documents/repos/network-automation/ansible.cfg
  configured module search path = ['/home/colin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/colin/Documents/repos/network-automation/.venv/lib/python3.11/site-packages/ansible
  ansible collection location = /home/colin/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/colin/Documents/repos/network-automation/.venv/bin/ansible
  python version = 3.11.6 (main, Nov 17 2023, 19:50:28) [GCC 13.2.1 20231011 (Red Hat 13.2.1-4)] (/home/colin/Documents/repos/network-automation/.venv/bin/python3)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
ansible-galaxy collection list cisco.ios
Collection Version
---------- -------
cisco.ios  6.1.0  
CONFIGURATION
CONFIG_FILE() = /home/colin/Documents/repos/network-automation/ansible.cfg
DEFAULT_HOST_LIST(/home/colin/Documents/repos/network-automation/ansible.cfg) = ['/home/colin/Documents/repos/network-automation/inventory/>
EDITOR(env: EDITOR) = /usr/bin/nano
OS / ENVIRONMENT

Operating System: Fedora 38. Cisco Switch: WS-C3560CX-8PC-S Cisco Version: 15.2(7)E9

STEPS TO REPRODUCE

Get facts:

- name: Gather all legacy facts
  cisco.ios.ios_facts:
    gather_subset: all
    gather_network_resources: service

Or modify ios_service:

- name: Manage Services
  cisco.ios.ios_service:
    config:
      config: true
      dhcp: false
      slave_log: false
EXPECTED RESULTS

I expect the ios_fact -> ansible_network_resources to return the correct state of services - in my scenario of disabling dhcp and slave_log it should return:

"ansible_network_resources": {
  "service": {
      "config": true,
      "counters": 0,
      "dhcp": false,
      "password_recovery": true,
      "prompt": true,
      "slave_log": false
  }
}

I also expect ios_service to detect dhcp and slave_log as false and not attempt to re-apply settings or show the task as changed

ACTUAL RESULTS

For ios_service:

TASK [ios_switch : Manage Services] ****************************************************************************************
task path: /home/colin/Documents/repos/network-automation/roles/ios_switch/tasks/base.yml:27
Loading collection ansible.utils from /home/colin/.ansible/collections/ansible_collections/ansible/utils
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<192.168.9.20> Using network group action cisco.ios.ios for cisco.ios.ios_service
<192.168.9.20> attempting to start connection
<192.168.9.20> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/colin/Documents/repos/network-automation/.venv/bin/ansible-connection
<192.168.9.20> found existing local domain socket, using it!
<192.168.9.20> updating play_context for connection
<192.168.9.20> Loading collection ansible.builtin from 
<192.168.9.20> local domain socket path is /home/colin/.ansible/pc/23c4b01f41
<192.168.9.20> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<192.168.9.20> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_service  at /home/colin/.ansible/collections/ansible_collections/cisco/ios/plugins/modules/ios_service.py
<192.168.9.20> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_service
<192.168.9.20> ANSIBLE_NETWORK_IMPORT_MODULES: complete
<192.168.9.20> ANSIBLE_NETWORK_IMPORT_MODULES: Result: {'commands': ['no service dhcp', 'no service slave-log'], 'before': {'config': True, 'prompt': True, 'counters': 0, 'dhcp': True, 'password_recovery': True, 'slave_log': True}, 'after': {'config': True, 'prompt': True, 'counters': 0, 'dhcp': True, 'password_recovery': True, 'slave_log': True}, 'changed': True, 'invocation': {'module_args': {'config': {'dhcp': False, 'slave_log': False, 'config': True, 'counters': 0, 'password_recovery': True, 'prompt': True, 'call_home': None, 'compress_config': None, 'disable_ip_fast_frag': None, 'exec_callback': None, 'exec_wait': None, 'hide_telnet_addresses': None, 'internal': None, 'linenumber': None, 'log': None, 'log_hidden': None, 'nagle': None, 'old_slip_prompts': None, 'pad': None, 'pad_cmns': None, 'pad_from_xot': None, 'pad_to_xot': None, 'password_encryption': None, 'private_config_encryption': None, 'pt_vty_logging': None, 'scripting': None, 'sequence_numbers': None, 'slave_coredump': None, 'tcp_keepalives_in': None, 'tcp_keepalives_out': None, 'tcp_small_servers': None, 'telnet_zeroidle': None, 'timestamps': None, 'udp_small_servers': None, 'unsupported_transceiver': None}, 'state': 'merged', 'running_config': None}}, '_ansible_parsed': True}
changed: [cosmo] => {
    "after": {
        "config": true,
        "counters": 0,
        "dhcp": true,
        "password_recovery": true,
        "prompt": true,
        "slave_log": true
    },
    "before": {
        "config": true,
        "counters": 0,
        "dhcp": true,
        "password_recovery": true,
        "prompt": true,
        "slave_log": true
    },
    "changed": true,
    "commands": [
        "no service dhcp",
        "no service slave-log"
    ],
    "invocation": {
        "module_args": {
            "config": {
                "call_home": null,
                "compress_config": null,
                "config": true,
                "counters": 0,
                "dhcp": false,
                "disable_ip_fast_frag": null,
                "exec_callback": null,
                "exec_wait": null,
                "hide_telnet_addresses": null,
                "internal": null,
                "linenumber": null,
                "log": null,
                "log_hidden": null,
                "nagle": null,
                "old_slip_prompts": null,
                "pad": null,
                "pad_cmns": null,
                "pad_from_xot": null,
                "pad_to_xot": null,
                "password_encryption": null,
                "password_recovery": true,
                "private_config_encryption": null,
                "prompt": true,
                "pt_vty_logging": null,
                "scripting": null,
                "sequence_numbers": null,
                "slave_coredump": null,
                "slave_log": false,
                "tcp_keepalives_in": null,
                "tcp_keepalives_out": null,
                "tcp_small_servers": null,
                "telnet_zeroidle": null,
                "timestamps": null,
                "udp_small_servers": null,
                "unsupported_transceiver": null
            },
            "running_config": null,
            "state": "merged"
        }
    }
}
redirecting (type: action) cisco.ios.ios_logging_global to cisco.ios.ios
roverflow commented 3 months ago

Hello @cfergs, appreciate you creating the issue. Upon reviewing the details mentioned, I observed that you're using IOS 15.2(7)E9. just wanted to let you know that we do not officially support 15.x devices. Hence this will be a no fix. Feel free to reach out for any other concerns.