ansible-collections / dellemc.os10

GNU General Public License v3.0
37 stars 49 forks source link

DellOS10_Facts: ansible_net_config is empty/"None" #23

Open Akasurde opened 4 years ago

Akasurde commented 4 years ago

From @Solace7 on Jun 24, 2020 23:27

SUMMARY

ansible_net_config variable is not showing running configuration

ISSUE TYPE
COMPONENT NAME

dellos10_facts

ANSIBLE VERSION
ansible 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Host OS: CentOS 07 VM (ESXi ) Python version: 2.7.5

Tested On: Two Dell MX9116n running Dell OS 10.5.0.2.468

STEPS TO REPRODUCE

Run playbook to gather dellos10_facts.

 gather_facts: yes
  connection: network_cli
  vars:
      ansible_network_os: 'dellos10'
      ansible_ssh_user: 'swadmin'
      ansible_ssh_pass: '********'
  tasks:
    - name: get configuration
      dellos10_facts:
        gather_subset:
          - config
      register: facts
    - name: Debug
      debug:
        msg: "{{ facts }}"
EXPECTED RESULTS

Expected facts.ansible_facts.ansible_net_config to show running-configuration

ACTUAL RESULTS

ansible_net_config has value of "None" or ""

ok: [192.168.161.251] => {
    "msg": {
        "ansible_facts": {
            "ansible_net_config": "",
            "ansible_net_gather_subset": [
                "default",
                "config"
            ],
            "ansible_net_hostname": "win-tx-sw-core01",
            "ansible_net_model": "MX9116N-ON",
            "ansible_net_name": "Enterprise",
            "ansible_net_servicetag": "B527Z23",
            "ansible_net_version": "10.5.0.2"
        },
        "changed": false,
        "failed": false
    }
}
ok: [192.168.161.252] => {
    "msg": {
        "ansible_facts": {
            "ansible_net_config": "None",
            "ansible_net_gather_subset": [
                "default",
                "config"
            ],
            "ansible_net_hostname": "win-tx-sw-core02",
            "ansible_net_model": "MX9116N-ON",
            "ansible_net_name": "Enterprise",
            "ansible_net_servicetag": "8LT1Z23",
            "ansible_net_version": "10.5.0.2"
        },
        "changed": false,
        "failed": false
    }
}

Copied from original issue: ansible/ansible#70282

woyteck1 commented 4 years ago

I shall add that dellos10_system does something similar for me on ansible 2.9.13

TASK [dellemc.os10.os10_system : Provisioning system configuration for os10] ************************************************************************************************** task path: /home/wojciechk/.ansible/collections/ansible_collections/dellemc/os10/roles/os10_system/tasks/main.yml:11 The full traceback is: File "/tmp/ansible_os10_config_payload_brw7rt_o/ansible_os10_config_payload.zip/ansible_collections/dellemc/os10/plugins/module_utils/network/os10.py", line 80, in get_config return _DEVICE_CONFIGS[cmd] fatal: [lon1sw1]: FAILED! => { "changed": false, "invocation": { "module_args": { "after": null, "backup": false, "backup_options": null, "before": null, "config": null, "lines": null, "match": "line", "parents": null, "provider": null, "replace": "line", "save": false, "src": "os10_system.j2", "update": "merge" } }, "msg": "unable to retrieve current config", "stderr": "Unable to decode JSON from response to exec_command(show running-configuration). Received 'None'.", "stderr_lines": [ "Unable to decode JSON from response to exec_command(show running-configuration). Received 'None'." ] }

Would be great if someone had a look at it. It is possible this may be related to this issue: https://github.com/ansible/ansible/issues/33643

gundalow commented 4 years ago

@skg-net is this something you'd be able to look at?

javeedf commented 4 years ago

@skg-net is this something you'd be able to look at?

Sure we will look into it

javeedf commented 4 years ago

I shall add that dellos10_system does something similar for me on ansible 2.9.13

TASK [dellemc.os10.os10_system : Provisioning system configuration for os10] ************************************************************************************************** task path: /home/wojciechk/.ansible/collections/ansible_collections/dellemc/os10/roles/os10_system/tasks/main.yml:11 The full traceback is: File "/tmp/ansible_os10_config_payload_brw7rt_o/ansible_os10_config_payload.zip/ansible_collections/dellemc/os10/plugins/module_utils/network/os10.py", line 80, in get_config return _DEVICE_CONFIGS[cmd] fatal: [lon1sw1]: FAILED! => { "changed": false, "invocation": { "module_args": { "after": null, "backup": false, "backup_options": null, "before": null, "config": null, "lines": null, "match": "line", "parents": null, "provider": null, "replace": "line", "save": false, "src": "os10_system.j2", "update": "merge" } }, "msg": "unable to retrieve current config", "stderr": "Unable to decode JSON from response to exec_command(show running-configuration). Received 'None'.", "stderr_lines": [ "Unable to decode JSON from response to exec_command(show running-configuration). Received 'None'." ] }

Would be great if someone had a look at it. It is possible this may be related to this issue: ansible/ansible#33643

Meanwhile please increase the command timeout to 60 sec and run again?

parkrish commented 4 years ago

@woyteck1 , the original issue filed was MX Platform specific. The issue you have reported with os10_system, I think is because of using Ansible 2.9 with OS10 collections. The OS10 collections needs to be used with Ansible 2.10.

In case you are trying OS10 collections with Ansible 2.9, please set the following environment variable and retry. export ANSIBLE_NETWORK_GROUP_MODULES=os10

woyteck1 commented 4 years ago

Hi @parkrish, I just tried your suggestion for environment variable and this is the output: `TASK [dellemc.os10.os10_system : Provisioning system configuration for os10] ** task path: /home/wojciechk/.ansible/collections/ansible_collections/dellemc/os10/roles/os10_system/tasks/main.yml:11 The full traceback is: Traceback (most recent call last): File "/home/wojciechk/git/auto/.venv/local/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 147, in run res = self._execute() File "/home/wojciechk/git/auto/.venv/local/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 665, in _execute result = self._handler.run(task_vars=variables) File "/home/wojciechk/.ansible/collections/ansible_collections/dellemc/os10/plugins/action/os10.py", line 87, in run out = conn.get_prompt() File "/home/wojciechk/git/auto/.venv/local/lib/python2.7/site-packages/ansible/module_utils/connection.py", line 185, in rpc raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code) ConnectionError: paramiko is not installed: No module named paramiko fatal: [lon1sw1]: FAILED! => { "msg": "Unexpected failure during module execution.", "stdout": "" }

`

I will now try upgrading ansible to 2.10

the timeout set to 30 seconds didn't help either.

parkrish commented 4 years ago

@woyteck1 , The error suggests paramiko package is not installed. Please install it to resolve the error(pip install paramiko)

woyteck1 commented 4 years ago

oh - just noticed that as well - but the good news is, that it works with ansible 2.10.rc1 as well once paramiko is installed. I must have uninstalled it and then didn't notice.

Thanks for your help!!