ansible-collections / ansible.netcommon

Ansible Network Collection for Common Code
GNU General Public License v3.0
144 stars 104 forks source link

Can't execute 'enable' commands ios_config on Cisco SF302-08PP #184

Open Akasurde opened 3 years ago

Akasurde commented 3 years ago

From @soloduy1 on Dec 02, 2020 18:58

SUMMARY

Can't execute 'enable' commands ios_config on Cisco SF302-08PP I get this error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: operation requires privilege escalation
fatal: [192.168.1.23]: FAILED! => changed=false

Inventory: [test] 192.168.1.23

[test:vars] become=yes become_method=enable ansible_become_password=PASSWORD ansible_connection=network_cli ansible_network_os=ios ansible_ssh_pass=PASSWORD ansible_ssh_user=cisco ansible_common_args="-oKexAlgorithms=+diffie-hellman-group1-sha1 -c 3des-cbc" ansible_python_interpreter="python" ansible_persistent_log_messages=true

ISSUE TYPE
COMPONENT NAME

ansible/plugins/connection/network_cli.py

ANSIBLE VERSION
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
CONFIGURATION
DEFAULT_BECOME(/etc/ansible/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/etc/ansible/ansible.cfg) = enable
DEFAULT_BECOME_USER(/etc/ansible/ansible.cfg) = cisco
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/etc/ansible/hosts']
DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /etc/ansible/ansible.log
DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 10
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
PARAMIKO_LOOK_FOR_KEYS(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Ansible Server is running on Ubuntu 18.04

Cisco SF302-08PP - NOT WORKING SW version 1.4.11.5 ( date 08-Apr-2020 time 13:49:34 ) Boot version 1.3.5.06 ( date 21-Jul-2013 time 15:12:10 ) HW version V04

STEPS TO REPRODUCE

sudo ansible-playbook test.yml -b -K

---
- name: test
  hosts: test
  gather_facts: false

  tasks:

   - name: setup ssh
     ios_config:
       commands:
       - ip ssh server
     become: yes
     become_method: enable
EXPECTED RESULTS
ACTUAL RESULTS
manager@ansible:/etc/ansible$ sudo ansible-playbook cisco.yml -b -K -vvvvv
ansible-playbook 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.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.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
BECOME 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 ini plugin
Loading callback plugin yaml of type stdout, v2.0 from /usr/lib/python3/dist-packages/ansible/plugins/callback/yaml.py

PLAYBOOK: test.yml ***********************************************************************************************************************************************************************************************************************
Positional arguments: test.yml
verbosity: 5
connection: smart
timeout: 10
become: True
become_method: enable
become_ask_pass: True
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in cisco.yml

PLAY [test] ******************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [configure interface settings] *******************************************************************************************************************************************************************************************************
task path: /etc/ansible/test.yml:8
<192.168.1.23> attempting to start connection
<192.168.1.23> using connection plugin network_cli
<192.168.1.23> local domain socket does not exist, starting it
<192.168.1.23> control socket path is /root/.ansible/pc/f0920c075c
<192.168.1.23> local domain socket listeners started successfully
<192.168.1.23> loaded cliconf plugin ios from path /usr/lib/python3/dist-packages/ansible/plugins/cliconf/ios.py for network_os ios
[WARNING]: Persistent connection logging is enabled for 192.168.1.23. This will log ALL interactions to /etc/ansible/ansible.log and WILL NOT redact sensitive configuration like passwords. USE WITH CAUTION!
<192.168.1.23>
<192.168.1.23> local domain socket path is /root/.ansible/pc/f0920c075c
<192.168.1.23> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.1.23> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064 `" && echo ansible-tmp-1606934811.6189237-197487907250064="` echo /root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064 `" ) && sleep 0'
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/network/common/config.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/network/common/__init__.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/network/__init__.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/network/ios/__init__.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/_text.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/connection.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/basic.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/network/ios/ios.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/six/__init__.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/network/common/utils.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/parsing/__init__.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/_collections_compat.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/network.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/__init__.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/json.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/collections.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/pycompat24.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/text/formatters.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/_json_compat.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/text/__init__.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/file.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/_utils.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/process.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/text/converters.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/validation.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/sys_info.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/common/parameters.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/distro/__init__.py
Using module_utils file /usr/lib/python3/dist-packages/ansible/module_utils/distro/_distro.py
Using module file /usr/lib/python3/dist-packages/ansible/modules/network/ios/ios_config.py
<192.168.1.23> PUT /root/.ansible/tmp/ansible-local-6428932017pf/tmp2uq0kz99 TO /root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py
<192.168.1.23> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/ /root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py && sleep 0'
<192.168.1.23> EXEC /bin/sh -c 'python /root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py && sleep 0'
<192.168.1.23> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py", line 102, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.network.ios.ios_config', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python2.7/runpy.py", line 188, in run_module
    fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/ansible_ios_config_payload_80Mzna/ansible_ios_config_payload.zip/ansible/modules/network/ios/ios_config.py", line 569, in <module>
  File "/tmp/ansible_ios_config_payload_80Mzna/ansible_ios_config_payload.zip/ansible/modules/network/ios/ios_config.py", line 500, in main
  File "/tmp/ansible_ios_config_payload_80Mzna/ansible_ios_config_payload.zip/ansible/modules/network/ios/ios_config.py", line 364, in edit_config_or_macro
  File "/tmp/ansible_ios_config_payload_80Mzna/ansible_ios_config_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
ansible.module_utils.connection.ConnectionError: operation requires privilege escalation
fatal: [192.168.1.23]: FAILED! => changed=false
  module_stderr: |-
    Traceback (most recent call last):
      File "/root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py", line 102, in <module>
        _ansiballz_main()
      File "/root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py", line 94, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/root/.ansible/tmp/ansible-local-6428932017pf/ansible-tmp-1606934811.6189237-197487907250064/AnsiballZ_ios_config.py", line 40, in invoke_module
        runpy.run_module(mod_name='ansible.modules.network.ios.ios_config', init_globals=None, run_name='__main__', alter_sys=True)
      File "/usr/lib/python2.7/runpy.py", line 188, in run_module
        fname, loader, pkg_name)
      File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
        mod_name, mod_fname, mod_loader, pkg_name)
      File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
        exec code in run_globals
      File "/tmp/ansible_ios_config_payload_80Mzna/ansible_ios_config_payload.zip/ansible/modules/network/ios/ios_config.py", line 569, in <module>
      File "/tmp/ansible_ios_config_payload_80Mzna/ansible_ios_config_payload.zip/ansible/modules/network/ios/ios_config.py", line 500, in main
      File "/tmp/ansible_ios_config_payload_80Mzna/ansible_ios_config_payload.zip/ansible/modules/network/ios/ios_config.py", line 364, in edit_config_or_macro
      File "/tmp/ansible_ios_config_payload_80Mzna/ansible_ios_config_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
    ansible.module_utils.connection.ConnectionError: operation requires privilege escalation
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

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

Copied from original issue: ansible/ansible#72793

Qalthos commented 3 years ago

This sounds like an issue that should be fixed in the netcommon collection. Can you verify if it is fixed when using the collection?

If this is that issue, we can look into backporting the fix to 2.9.

soloduy1 commented 3 years ago

This sounds like an issue that should be fixed in the netcommon collection. Can you verify if it is fixed when using the collection?

If this is that issue, we can look into backporting the fix to 2.9.

Thanks for the answer!

This problem is still relevant to me, I would be glad if it can be fixed

Qalthos commented 3 years ago

And I am trying to tell you that I think it is fixed, but I need more information from you to know whether that is true or not. Ansible 2.9.6 was released almost an entire year ago, and many fixes like this have gone in since then.

Can you please rerun this with ansible 2.10 and the latest released version of the ansible.netcommon collection and either report back that the issue is fixed, or provide a new log of the results?

soloduy1 commented 3 years ago

And I am trying to tell you that I think it is fixed, but I need more information from you to know whether that is true or not. Ansible 2.9.6 was released almost an entire year ago, and many fixes like this have gone in since then.

Can you please rerun this with ansible 2.10 and the latest released version of the ansible.netcommon collection and either report back that the issue is fixed, or provide a new log of the results?

I'm trying this on Ansible 2.10, but I still get this:

NETCOMMON VERSION
manager@ansible:/etc/ansible$ sudo ansible-galaxy collection list

# /root/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon 1.4.1
ANSIBLE VERSION
  ansible 2.10.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/manager/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
CONFIGURATION
DEFAULT_BECOME(/etc/ansible/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/etc/ansible/ansible.cfg) = enable
DEFAULT_BECOME_USER(/etc/ansible/ansible.cfg) = cisco
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/etc/ansible/hosts']
DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /etc/ansible/ansible.log
DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 10
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
PARAMIKO_LOOK_FOR_KEYS(/etc/ansible/ansible.cfg) = False
INVENTORY
Inventory:
[test]
192.168.1.23

[test:vars]
become=yes
become_method=enable
ansible_become_password=PASSWORD
ansible_connection=network_cli
ansible_network_os=ios
ansible_ssh_pass=PASSWORD
ansible_ssh_user=cisco
ansible_common_args="-oKexAlgorithms=+diffie-hellman-group1-sha1 -c 3des-cbc"
ansible_python_interpreter="python3"
ansible_persistent_log_messages=true
STEPS TO REPRODUCE

sudo ansible-playbook test.yml -b -K

- name: test
  hosts: test
  gather_facts: false

  tasks:

   - name: setup ssh
     ios_config:
       commands:
       - ip ssh server
     become: yes
     become_method: enable
ACTUAL RESULTS
manager@ansible:/etc/ansible$ sudo ansible-playbook test.yml -b -K -vvvvvv
ansible-playbook 2.10.4
  config file = /etc/ansible/ansible.cfg
  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
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
BECOME 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 ini plugin
redirecting (type: modules) ansible.builtin.ios_config to cisco.ios.ios_config
Loading collection cisco.ios from /usr/local/lib/python3.8/dist-packages/ansible_collections/cisco/ios
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
Loading collection community.general from /usr/local/lib/python3.8/dist-packages/ansible_collections/community/general
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
Loading callback plugin community.general.yaml of type stdout, v2.0 from /usr/local/lib/python3.8/dist-packages/ansible_collections/community/general/plugins/callback/yaml.py
Attempting to use 'default' callback.
Skipping callback 'default', as we already have a stdout callback.
Attempting to use 'junit' callback.
Attempting to use 'minimal' callback.
Skipping callback 'minimal', as we already have a stdout callback.
Attempting to use 'oneline' callback.
Skipping callback 'oneline', as we already have a stdout callback.
Attempting to use 'tree' callback.

PLAYBOOK: test.yml **************************************************************************************************************************************************
Positional arguments: test.yml
verbosity: 6
connection: smart
timeout: 10
become: True
become_method: enable
become_ask_pass: True
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in test.yml

PLAY [test] *********************************************************************************************************************************************************
META: ran handlers

TASK [setup ssh] ****************************************************************************************************************************************************
task path: /etc/ansible/test.yml:8
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.netcommon from /root/.ansible/collections/ansible_collections/ansible/netcommon
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<192.168.1.23> attempting to start connection
<192.168.1.23> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/local/bin/ansible-connection
<192.168.1.23> local domain socket does not exist, starting it
<192.168.1.23> control socket path is /root/.ansible/pc/cfa004bf04
<192.168.1.23> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<192.168.1.23> Loading collection ansible.netcommon from /root/.ansible/collections/ansible_collections/ansible/netcommon
<192.168.1.23> redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
<192.168.1.23> Loading collection cisco.ios from /usr/local/lib/python3.8/dist-packages/ansible_collections/cisco/ios
<192.168.1.23> redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<192.168.1.23> local domain socket listeners started successfully
<192.168.1.23> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /usr/local/lib/python3.8/dist-packages/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os ios
[WARNING]: Persistent connection logging is enabled for 192.168.1.23. This will log ALL interactions to /etc/ansible/ansible.log and WILL NOT redact sensitive
configuration like passwords. USE WITH CAUTION!
<192.168.1.23>
<192.168.1.23> local domain socket path is /root/.ansible/pc/cfa004bf04
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<192.168.1.23> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.1.23> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-580951inyr7g9 `"&& mkdir "` echo /root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928 `" && echo ansible-tmp-1610490998.1943858-58099-273166829458928="` echo /root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.ios_config to cisco.ios.ios_config
Including module_utils file ansible/__init__.py
Including module_utils file ansible/module_utils/__init__.py
Including module_utils file ansible/module_utils/_text.py
Including module_utils file ansible/module_utils/basic.py
Including module_utils file ansible/module_utils/common/_collections_compat.py
Including module_utils file ansible/module_utils/common/__init__.py
Including module_utils file ansible/module_utils/common/_json_compat.py
Including module_utils file ansible/module_utils/common/_utils.py
Including module_utils file ansible/module_utils/common/file.py
Including module_utils file ansible/module_utils/common/parameters.py
Including module_utils file ansible/module_utils/common/collections.py
Including module_utils file ansible/module_utils/common/process.py
Including module_utils file ansible/module_utils/common/sys_info.py
Including module_utils file ansible/module_utils/common/text/converters.py
Including module_utils file ansible/module_utils/common/text/__init__.py
Including module_utils file ansible/module_utils/common/text/formatters.py
Including module_utils file ansible/module_utils/common/validation.py
Including module_utils file ansible/module_utils/common/warnings.py
Including module_utils file ansible/module_utils/compat/selectors.py
Including module_utils file ansible/module_utils/compat/__init__.py
Including module_utils file ansible/module_utils/compat/_selectors2.py
Including module_utils file ansible/module_utils/connection.py
Including module_utils file ansible/module_utils/common/json.py
Including module_utils file ansible/module_utils/distro/__init__.py
Including module_utils file ansible/module_utils/distro/_distro.py
Including module_utils file ansible/module_utils/parsing/convert_bool.py
Including module_utils file ansible/module_utils/parsing/__init__.py
Including module_utils file ansible/module_utils/pycompat24.py
Including module_utils file ansible/module_utils/six/__init__.py
Including module_utils file ansible_collections/ansible/netcommon/plugins/module_utils/network/common/config.py
Including module_utils file ansible_collections/__init__.py
Including module_utils file ansible_collections/ansible/__init__.py
Including module_utils file ansible_collections/ansible/netcommon/__init__.py
Including module_utils file ansible_collections/ansible/netcommon/plugins/__init__.py
Including module_utils file ansible_collections/ansible/netcommon/plugins/module_utils/__init__.py
Including module_utils file ansible_collections/ansible/netcommon/plugins/module_utils/network/__init__.py
Including module_utils file ansible_collections/ansible/netcommon/plugins/module_utils/network/common/__init__.py
Including module_utils file ansible_collections/cisco/ios/plugins/module_utils/network/ios/ios.py
Including module_utils file ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py
Including module_utils file ansible/module_utils/common/network.py
Including module_utils file ansible_collections/cisco/__init__.py
Including module_utils file ansible_collections/cisco/ios/__init__.py
Including module_utils file ansible_collections/cisco/ios/plugins/__init__.py
Including module_utils file ansible_collections/cisco/ios/plugins/module_utils/__init__.py
Including module_utils file ansible_collections/cisco/ios/plugins/module_utils/network/__init__.py
Including module_utils file ansible_collections/cisco/ios/plugins/module_utils/network/ios/__init__.py
Using module file /usr/local/lib/python3.8/dist-packages/ansible_collections/cisco/ios/plugins/modules/ios_config.py
<192.168.1.23> PUT /root/.ansible/tmp/ansible-local-580951inyr7g9/tmp7ch6mvk6 TO /root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py
<192.168.1.23> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/ /root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py && sleep 0'
<192.168.1.23> EXEC /bin/sh -c 'python3 /root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py && sleep 0'
<192.168.1.23> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py", line 102, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.cisco.ios.plugins.modules.ios_config', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_ios_config_payload_id2x29pl/ansible_ios_config_payload.zip/ansible_collections/cisco/ios/plugins/modules/ios_config.py", line 577, in <module>
  File "/tmp/ansible_ios_config_payload_id2x29pl/ansible_ios_config_payload.zip/ansible_collections/cisco/ios/plugins/modules/ios_config.py", line 502, in main
  File "/tmp/ansible_ios_config_payload_id2x29pl/ansible_ios_config_payload.zip/ansible_collections/cisco/ios/plugins/modules/ios_config.py", line 376, in edit_config_or_macro
  File "/tmp/ansible_ios_config_payload_id2x29pl/ansible_ios_config_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
ansible.module_utils.connection.ConnectionError: operation requires privilege escalation
fatal: [192.168.1.23]: FAILED! => changed=false
  module_stderr: |-
    Traceback (most recent call last):
      File "/root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py", line 102, in <module>
        _ansiballz_main()
      File "/root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py", line 94, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/root/.ansible/tmp/ansible-local-580951inyr7g9/ansible-tmp-1610490998.1943858-58099-273166829458928/AnsiballZ_ios_config.py", line 40, in invoke_module
        runpy.run_module(mod_name='ansible_collections.cisco.ios.plugins.modules.ios_config', init_globals=None, run_name='__main__', alter_sys=True)
      File "/usr/lib/python3.8/runpy.py", line 207, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_ios_config_payload_id2x29pl/ansible_ios_config_payload.zip/ansible_collections/cisco/ios/plugins/modules/ios_config.py", line 577, in <module>
      File "/tmp/ansible_ios_config_payload_id2x29pl/ansible_ios_config_payload.zip/ansible_collections/cisco/ios/plugins/modules/ios_config.py", line 502, in main
      File "/tmp/ansible_ios_config_payload_id2x29pl/ansible_ios_config_payload.zip/ansible_collections/cisco/ios/plugins/modules/ios_config.py", line 376, in edit_config_or_macro
      File "/tmp/ansible_ios_config_payload_id2x29pl/ansible_ios_config_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
    ansible.module_utils.connection.ConnectionError: operation requires privilege escalation
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

PLAY RECAP **********************************************************************************************************************************************************
192.168.1.23               : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
JCTechSol commented 3 years ago

I get the same issue. I think this has to due with the SF302's using a half-baked version of ios.

I've worked around it by using ios_command with conf as the first line:

  - name: Configure Port(s)
    ios_command:
      commands:
      - conf 
      - int range "{{ ports }}"
      - no description
      - negotiation {{ SPEED }}
      - no power inline limit
      - power inline auto
      - no port security
      - no dot1x authentication
      - no dot1x port-control
      - switch trunk allow vlan add "{{ VOICE }}"
      - switch trunk native vlan "{{ RESVLAN }}"
soloduy1 commented 3 years ago

I get the same issue. I think this has to due with the SF302's using a half-baked version of ios.

I've worked around it by using ios_command with conf as the first line:

  - name: Configure Port(s)
    ios_command:
      commands:
      - conf 
      - int range "{{ ports }}"
      - no description
      - negotiation {{ SPEED }}
      - no power inline limit
      - power inline auto
      - no port security
      - no dot1x authentication
      - no dot1x port-control
      - switch trunk allow vlan add "{{ VOICE }}"
      - switch trunk native vlan "{{ RESVLAN }}"

Yep, i used this method. This issue can be closed, Cisco Small Business uses a different IOS version, which is not yet supported in Ansible. I found a solution to this problem for myself through using the Napalm library for Cisco SG-xxx.