ansible-collections / dellemc.os10

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

Exception AssertionError: socket_path must be a value #95

Open davibaldin opened 3 years ago

davibaldin commented 3 years ago
SUMMARY

A very simple playbook cannot contact device. Workstation is working file for other playbooks.

ISSUE TYPE
ANSIBLE VERSION
ansible [core 2.11.4] 
  config file = None
  configured module search path = ['/Users/davi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/davi/Library/Python/3.8/lib/python/site-packages/ansible
  ansible collection location = /Users/davi/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/davi/Library/Python/3.8/bin/ansible
  python version = 3.8.2 (default, Jun  8 2021, 11:59:35) [Clang 12.0.5 (clang-1205.0.22.11)]
  jinja version = 3.0.1
  libyaml = False
COLLECTION VERSION
# /Users/davi/Library/Python/3.8/lib/python/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 3.5.0  

# /Users/davi/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 3.6.0  
CONFIGURATION
No changes
OS / ENVIRONMENT

MacOS BugSur M1

STEPS TO REPRODUCE
- name: Dell Switch OS10 Backup configuration
  gather_facts: false
  hosts: all

  tasks:
  - name: run show version on remote devices
    dellemc.os10.os10_command:
      commands: show version

ansible-playbook -i "172.16.0.100," dell-os10-backup-config.yml -u admin -k -vvv

EXPECTED RESULTS

Success.

ACTUAL RESULTS

Playbook error

ansible-playbook [core 2.11.4] 
  config file = None
  configured module search path = ['/Users/davi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/davi/Library/Python/3.8/lib/python/site-packages/ansible
  ansible collection location = /Users/davi/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/davi/Library/Python/3.8/bin/ansible-playbook
  python version = 3.8.2 (default, Jun  8 2021, 11:59:35) [Clang 12.0.5 (clang-1205.0.22.11)]
  jinja version = 3.0.1
  libyaml = False
No config file found; using defaults
SSH password: 
setting up inventory plugins
Parsed 172.16.0.100, inventory source with host_list plugin
Loading collection dellemc.os10 from /Users/davi/.ansible/collections/ansible_collections/dellemc/os10
redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10
Loading callback plugin default of type stdout, v2.0 from /Users/davi/Library/Python/3.8/lib/python/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: dell-os10-backup-config.yml ************************************************************************************************
Positional arguments: dell-os10-backup-config.yml
verbosity: 4
ask_pass: True
remote_user: admin
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('172.16.0.100,',)
forks: 5
1 plays in dell-os10-backup-config.yml

PLAY [Dell Switch OS10 Backup configuration] *****************************************************************************************
META: ran handlers
redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10
Loading collection ansible.netcommon from /Users/davi/.ansible/collections/ansible_collections/ansible/netcommon

TASK [run show version on remote devices] ********************************************************************************************
task path: /Users/davi/Development/Workspaces/anext/Ansible/playbook/networking/dell-os10-backup-config.yml:6
redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10
redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10
The full traceback is:
Traceback (most recent call last):
  File "/Users/davi/Library/Python/3.8/lib/python/site-packages/ansible/executor/task_executor.py", line 158, in run
    res = self._execute()
  File "/Users/davi/Library/Python/3.8/lib/python/site-packages/ansible/executor/task_executor.py", line 582, in _execute
    result = self._handler.run(task_vars=variables)
  File "/Users/davi/.ansible/collections/ansible_collections/dellemc/os10/plugins/action/os10.py", line 86, in run
    conn = Connection(socket_path)
  File "/Users/davi/Library/Python/3.8/lib/python/site-packages/ansible/module_utils/connection.py", line 124, in __init__
    raise AssertionError('socket_path must be a value')
AssertionError: socket_path must be a value
fatal: [172.16.0.100]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

PLAY RECAP ***************************************************************************************************************************
172.16.0.100               : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
prasadapr commented 2 years ago

@davibaldin:
There is no issue in the playbook or switch/dellemc.os10 collections side. The Issue is with the option which we have given in the ansible-playbook command. In multiple ways we can issue the ansible-playbook command with multiple options. I have tried with multiple options and its working fine. To make it work we have to follow few steps:

  1. First make sure that from Ansible controller we can access the switch/device via ssh.
  2. We can define the hosts in inventory file or /etc/ansible/hosts

In the current configuration, the reason for failure is: ansible-playbook -i "172.16.0.100," dell-os10-backup-config.yml -u admin -k -vvv

when we issue -i option - we have to provide name of the inventory file Ex: -i inventory.yaml

If we want to configure on particular host/node, we have to use --limit or -l option ( not -i) when we are using --limit or -l option, please make sure that ip addresses defined in the /etc/ansible/hosts

For example: cat /etc/ansible/hosts 172.16.0.100 ansible_ssh_user=xxxxx ansible_ssh_pass=xxxx ansible_network_os=dellemc.os10.os10 ansible connection=network_cli

prasadapr commented 2 years ago

Same error message reproduced with "-i " option:

root@Ubuntu20-vm-038-037:~/os10-ansible# ansible-playbook -i "100.104.40.188," os10_show-version-Issue_95.yaml -u admin -k -vvv ansible-playbook [core 2.12.0] config file = None configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible-playbook python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0] jinja version = 2.10.1 libyaml = True No config file found; using defaults SSH password: Parsed 100.104.40.188, inventory source with host_list plugin redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10 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: os10_show-version-Issue_95.yaml *** 1 plays in os10_show-version-Issue_95.yaml

PLAY [Dell Switch OS10 Backup configuration] **** META: ran handlers redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10 [WARNING]: Collection ansible.netcommon does not support Ansible version 2.12.0

TASK [run show version on remote devices] *** task path: /root/os10-ansible/os10_show-version-Issue_95.yaml:6 redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10 redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10 The full traceback is: Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/ansible/executor/task_executor.py", line 158, in run res = self._execute() File "/usr/local/lib/python3.8/dist-packages/ansible/executor/task_executor.py", line 589, in _execute result = self._handler.run(task_vars=variables) File "/root/.ansible/collections/ansible_collections/dellemc/os10/plugins/action/os10.py", line 86, in run conn = Connection(socket_path) File "/usr/local/lib/python3.8/dist-packages/ansible/module_utils/connection.py", line 124, in init raise AssertionError('socket_path must be a value') AssertionError: socket_path must be a value fatal: [100.104.40.188]: FAILED! => { "msg": "Unexpected failure during module execution.", "stdout": "" }

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

root@Ubuntu20-vm-038-037:~/os10-ansible#

prasadapr commented 2 years ago

Working scenario with "--limit or -l option"

root@Ubuntu20-vm-038-037:~/os10-ansible# ansible-playbook -l "100.104.40.188," os10_show-version-Issue_95.yaml -u admin -k -vvv ansible-playbook [core 2.12.0] config file = None configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible-playbook python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0] jinja version = 2.10.1 libyaml = True No config file found; using defaults SSH password: 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 ini plugin redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10 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: os10_show-version-Issue_95.yaml *** 1 plays in os10_show-version-Issue_95.yaml

PLAY [Dell Switch OS10 Backup configuration] **** META: ran handlers redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10 [WARNING]: Collection ansible.netcommon does not support Ansible version 2.12.0

TASK [run show version on remote devices] *** task path: /root/os10-ansible/os10_show-version-Issue_95.yaml:6 redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10 redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10 <100.104.40.188> ESTABLISH LOCAL CONNECTION FOR USER: root <100.104.40.188> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /root/.ansible/tmp/ansible-local-9788cyqk3iut"&& mkdir "echo /root/.ansible/tmp/ansible-local-9788cyqk3iut/ansible-tmp-1640610231.7725859-9795-167683172107117" && echo ansible-tmp-1640610231.7725859-9795-167683172107117="echo /root/.ansible/tmp/ansible-local-9788cyqk3iut/ansible-tmp-1640610231.7725859-9795-167683172107117" ) && sleep 0' Using module file /root/.ansible/collections/ansible_collections/dellemc/os10/plugins/modules/os10_command.py <100.104.40.188> PUT /root/.ansible/tmp/ansible-local-9788cyqk3iut/tmpkvr0rgdw TO /root/.ansible/tmp/ansible-local-9788cyqk3iut/ansible-tmp-1640610231.7725859-9795-167683172107117/AnsiballZ_os10_command.py <100.104.40.188> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-9788cyqk3iut/ansible-tmp-1640610231.7725859-9795-167683172107117/ /root/.ansible/tmp/ansible-local-9788cyqk3iut/ansible-tmp-1640610231.7725859-9795-167683172107117/AnsiballZ_os10_command.py && sleep 0' <100.104.40.188> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-local-9788cyqk3iut/ansible-tmp-1640610231.7725859-9795-167683172107117/AnsiballZ_os10_command.py && sleep 0' <100.104.40.188> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-9788cyqk3iut/ansible-tmp-1640610231.7725859-9795-167683172107117/ > /dev/null 2>&1 && sleep 0' ok: [100.104.40.188] => { "changed": false, "invocation": { "module_args": { "commands": [ "show version" ], "interval": 1, "match": "all", "provider": null, "retries": 10, "wait_for": null } }, "stdout": [ "Dell EMC Networking OS10 Enterprise\nCopyright (c) 1999-2021 by Dell Inc. All Rights Reserved.\nOS Version: 10.5.2.7\nBuild Version: 10.5.2.7.374\nBuild Time: 2021-07-28T04:48:16+0000\nSystem Type: S5248F-VM\nArchitecture: x86_64\nUp Time: 04:06:18" ], "stdout_lines": [ [ "Dell EMC Networking OS10 Enterprise", "Copyright (c) 1999-2021 by Dell Inc. All Rights Reserved.", "OS Version: 10.5.2.7", "Build Version: 10.5.2.7.374", "Build Time: 2021-07-28T04:48:16+0000", "System Type: S5248F-VM", "Architecture: x86_64", "Up Time: 04:06:18" ] ] } META: ran handlers META: ran handlers

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

root@Ubuntu20-vm-038-037:~/os10-ansible#

prasadapr commented 2 years ago

@davibaldin, by any chance have you tried with provided steps/command : "--limit or -l option" if its working, shall we close this issue?

prasadapr commented 2 years ago

@davibaldin, have you tried with provided command : "--limit or -l option" Shall we close this issue, if it's working ?

prasadapr commented 2 years ago

I am waiting for your confirmation. @davibaldin, Shall we close this issue?

weakcamel commented 1 year ago

I'm facing the same problems on the latest os10 collection

$ ansible-playbook test.yml -vvv -l lon1sw1
ansible-playbook [core 2.13.7]
  config file = /Users/weakcamel/git/internal-networking/ansible.cfg
  configured module search path = ['/Users/weakcamel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/weakcamel/git/internal-networking/.venv/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/weakcamel/git/internal-networking/galaxy-collections
  executable location = /Users/weakcamel/git/internal-networking/.venv/bin/ansible-playbook
  python version = 3.9.16 (main, Dec  7 2022, 10:16:11) [Clang 14.0.0 (clang-1400.0.29.202)]
  jinja version = 3.1.2
  libyaml = True
Using /Users/weakcamel/git/internal-networking/ansible.cfg as config file
script declined parsing /Users/weakcamel/git/internal-networking/inventory/networking.yml as it did not pass its verify_file() method
Parsed /Users/weakcamel/git/internal-networking/inventory/networking.yml inventory source with yaml plugin
redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
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: test.yml *****************************************************************************************************************************************************************************************
1 plays in test.yml

PLAY [Dell Switch OS10 Backup configuration] ***************************************************************************************************************************************************************
META: ran handlers
redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10

TASK [run show version on remote devices] ******************************************************************************************************************************************************************
task path: /Users/weakcamel/git/internal-networking/test.yml:6
redirecting (type: lookup) ansible.builtin.hashi_vault to community.hashi_vault.hashi_vault
redirecting (type: lookup) ansible.builtin.hashi_vault to community.hashi_vault.hashi_vault
redirecting (type: lookup) ansible.builtin.hashi_vault to community.hashi_vault.hashi_vault
redirecting (type: lookup) ansible.builtin.hashi_vault to community.hashi_vault.hashi_vault
redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10
redirecting (type: action) dellemc.os10.os10_command to dellemc.os10.os10
The full traceback is:
Traceback (most recent call last):
  File "/Users/weakcamel/git/internal-networking/.venv/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 158, in run
    res = self._execute()
  File "/Users/weakcamel/git/internal-networking/.venv/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 647, in _execute
    result = self._handler.run(task_vars=vars_copy)
  File "/Users/weakcamel/git/internal-networking/galaxy-collections/ansible_collections/dellemc/os10/plugins/action/os10.py", line 87, in run
    conn = Connection(socket_path)
  File "/Users/weakcamel/git/internal-networking/.venv/lib/python3.9/site-packages/ansible/module_utils/connection.py", line 124, in __init__
    raise AssertionError('socket_path must be a value')
AssertionError: socket_path must be a value
fatal: [lon1sw1]: FAILED! =>
  msg: Unexpected failure during module execution.
  stdout: ''

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

For the record, this happens when Ansible connection plugin wasn't configured properly; adding it solved the problem:

$ cat inventory/group_vars/networking.yml
---
ansible_connection: ansible.netcommon.network_cli
ansible_network_os: dellemc.os10.os10
prasadapr commented 10 months ago

Hi @weakcamel, thank you for the update. Shall we close this issue?