GithubHelp home page GithubHelp logo

ansible-collections / community.ciscosmb Goto Github PK

View Code? Open in Web Editor NEW
20.0 7.0 9.0 300 KB

Ansible Galaxy module for Cisco SMB switches - SG300, SG500, SG350, SG550

Home Page: http://galaxy.ansible.com/community/ciscosmb

License: GNU General Public License v3.0

Python 100.00%
smb bussiness-switches cisco switch ansible ansible-collection

community.ciscosmb's People

Contributors

andersson007 avatar gundalow avatar jscooksey avatar mirceanton avatar qaxi avatar webknjaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

community.ciscosmb's Issues

How to pass STDIN to commands

SUMMARY

Possibly just an addition to documentation, I need to know how to pass STDIN to the module.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

Documentation -
Add documentation on how to pass things to STDIN (ie. when the command 'crypto certificate 2 import' is called it wants a certificate to be passed and a . on a new line).

ADDITIONAL INFORMATION

I believe there are multiple commands in the SMB CIOS which require this.

Note: arg: with stdin does NOT work.

 tasks:
        - name: set certificate 2
          community.ciscosmb.command:
            commands: 
             - conf
             - crypto certificate 2 import
            args:
                stdin: "-----BEGIN RSA PRIVATE KEY-----
-----END CERTIFICATE-----
.
"

Collection Requirements Violation - Semantic Versioning

SUMMARY

According to the changelog (https://github.com/ansible-collections/community.ciscosmb/blob/main/CHANGELOG.rst#v108), the bugfix 1.0.8 release contains a breaking change. This is explicitly prohibited by semantic versioning (https://semver.org/) - breaking changes must happen in new major versions.

Semantic versioning is one of the main collection requirements for inclusion in Ansible (https://docs.ansible.com/ansible/devel/community/collection_contributors/collection_requirements.html#versioning-and-deprecation).

In today's Ansible 9.5.0 release, we pinned community.ciscosmb to <1.0.8 to avoid breaking changes.

Please amend this breaking change and create a new 1.0.9 bugfix release without it as soon as possible, or risk freezing community.ciscosmb to 1.0.8 for the remainder of the Ansible 9 release cycle.

The breaking change was introduced here: #72 Better return both the old (misspelled) and the new fact until the next major release, and declare the misspelled one as deprecated.

Please also note that according to semver, deprecations have to happen in minor version releases, not in bugfix verison releases. So 1.0.9 should add the misspelled fact back, and 1.1.0 should deprecate the misspelled fact name.

ISSUE TYPE
  • Bug Report

Transfer tasks

  • Transfer repo
  • Update galaxy.yml and other documentation to refer to new name
  • Update workflows to use new collection name
  • Add Zuul to publish collection to galaxy under the community namespace (@gundalow)
  • Add other maintainers, who needs adding?
  • Publish final update to original collection with updated README.md pointing to this new collection
  • Deprecate old collection in Galaxy UI

bandwith not bandwidth

SUMMARY

the facts module seems to reference interface bandwidth as bandwith

ISSUE TYPE
  • Bug Report
COMPONENT NAME

/plugins/modules/facts.py

ANSIBLE VERSION
ansible [core 2.15.2]
  config file = /home/newera/ansible/ansible.cfg
  configured module search path = ['/home/newera/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/newera/.local/pipx/venvs/ansible/lib/python3.10/site-packages/ansible
  ansible collection location = /home/newera/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/newera/.local/bin/ansible
  python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (/home/newera/.local/pipx/venvs/ansible/bin/python)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection         Version
------------------ -------
community.ciscosmb 1.0.6 

NB can see in current 1.0.7 code on GitHub

CONFIGURATION
CONFIG_FILE() = /home/newera/ansible/ansible.cfg
DEFAULT_HOST_LIST(/home/newera/ansible/ansible.cfg) = ['/home/newera/ansible/inventory/netbox.yml']
HOST_KEY_CHECKING(/home/newera/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Ubuntu 22.04.2 LTS

STEPS TO REPRODUCE
- name: Get Raw JSON to examine on Interfaces
  hosts: device_roles_switch
  connection: local
  gather_facts: no
  vars:
    ansible_network_os: community.ciscosmb.ciscosmb

  tasks:
    - name: Collect Interfaces
      community.ciscosmb.facts:
        gather_subset:
          - interfaces

    - name: Debug Output
      debug:
        msg: "{{ ansible_facts }}"
EXPECTED RESULTS

Expected the term to be bandwidth with the d in it

ACTUAL RESULTS
    "net_interfaces": {
        "GigabitEthernet1/0/1": {
            "admin_state": "up",
            "bandwith": null,
            "control": null,
            "description": "9  PCs",
            "duplex": null,
            "mdix": "auto",
            "mode": null,
            "mtu": 1518,
            "negotiation": null,
            "presure": null,
            "state": "down",
            "type": "1G-Copper"
        },

Enable not working on SG300

SUMMARY

I'm trying to run commands from a privilege level 7 account that can elevate to 15 using enable. What I am finding is that the commands are not running, which seems to indicate that the elevation to privilege 15 is not happening. When I try to do the same reproduction steps with a privilege level 15 account, the issue does not appear.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.ciscosmb.command

ANSIBLE VERSION
ansible [core 2.15.9]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.18 (main, Feb 13 2024, 10:54:04) [GCC 12.2.0] (/usr/local/bin/python)
  jinja version = 3.1.3
  libyaml = True
COLLECTION VERSION
# /usr/local/lib/python3.9/site-packages/ansible_collections
Collection         Version
------------------ -------
community.ciscosmb 1.0.7  
CONFIGURATION

inventory.yml config for this switch:

switch1:
      ansible_host: xx.xx.xx.xx
      ansible_network_os: community.ciscosmb.ciscosmb
      ansible_ssh_private_key_file: ./cisco-privkey
      ansible_ssh_user: username
      ansible_become_method: "enable"
      ansible_become_password: "******"
      ansible_ssh_port: xxxx
      ansible_host_key_checking: false
      new_user_password: "example_password"
OS / ENVIRONMENT
NAME: "1"   DESCR: "SG300-20 20-Port Gigabit Managed Switch"
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

playbook task that doesn't work:

    - name: Set up ansible user account
      become: yes
      community.ciscosmb.command:
        commands:
          - config t
          - "username ansible password {{new_user_password}} privilege 15"
          - ip ssh pubkey-auth auto-login
          - exit
EXPECTED RESULTS

All commands work as expected

ACTUAL RESULTS

password and subsequent commands are not recognized, indicating that enable didn't activate properly

redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<192.168.42.104> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.42.104> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-1pwj0mr4g `"&& mkdir "` echo /root/.ansible/tmp/ansible-local-1pwj0mr4g/ansible-tmp-1710593382.4371493-9-223457125418386 `" && echo ansible-tmp-1710593382.4371493-9-223457125418386="` echo /root/.ansible/tmp/ansible-local-1pwj0mr4g/ansible-tmp-1710593382.4371493-9-223457125418386 `" ) && sleep 0'
Using module file /usr/local/lib/python3.9/site-packages/ansible_collections/community/ciscosmb/plugins/modules/command.py
<192.168.42.104> PUT /root/.ansible/tmp/ansible-local-1pwj0mr4g/tmp7_39ad_r TO /root/.ansible/tmp/ansible-local-1pwj0mr4g/ansible-tmp-1710593382.4371493-9-223457125418386/AnsiballZ_command.py
<192.168.42.104> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-1pwj0mr4g/ansible-tmp-1710593382.4371493-9-223457125418386/ /root/.ansible/tmp/ansible-local-1pwj0mr4g/ansible-tmp-1710593382.4371493-9-223457125418386/AnsiballZ_command.py && sleep 0'
<192.168.42.104> EXEC /bin/sh -c '/usr/local/bin/python /root/.ansible/tmp/ansible-local-1pwj0mr4g/ansible-tmp-1710593382.4371493-9-223457125418386/AnsiballZ_command.py && sleep 0'
<192.168.42.104> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-1pwj0mr4g/ansible-tmp-1710593382.4371493-9-223457125418386/ > /dev/null 2>&1 && sleep 0'
ok: [switch1_chkodama] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "commands": [
                "config t",
                "username ansible password example_password privilege 15",
                "ip ssh pubkey-auth auto-login",
                "exit"
            ],
            "interval": 1,
            "match": "all",
            "retries": 10,
            "wait_for": null
        }
    },
    "stdout": [
        "switch(config)#",
        "% Unrecognized command\nswitch(config)#",
        "% Unrecognized command\nswitch(config)#",
        "switch#"
    ],
    "stdout_lines": [
        [
            "switch(config)#"
        ],
        [
            "% Unrecognized command",
            "switch(config)#"
        ],
        [
            "% Unrecognized command",
            "switch(config)#"
        ],
        [
            "switch#"
        ]
    ]
}

Consider using true/false for all booleans in docs

Based on the community decision to use true/false for boolean values in documentation and examples, we ask that you evaluate booleans in this collection and consider changing any that do not use true/false (lowercase).

See documentation block format for more info (specifically, option defaults).

If you have already implemented this or decide not to, feel free to close this issue.


P.S. This is auto-generated issue, please raise any concerns here

Ansible Contributor Summit. Tuesday, April 12, 2022.

Ansible Contributor Summit

We are happy to announce that the registration for the Ansible Contributor Summit is open!

Why
  • This is a great opportunity for interested people to meet, discuss related topics, share their stories and opinions, get the latest important updates and just to hang out together.

  • There will be different announcements & presentations by Community, Core, Cloud, Network, and other teams.

  • Current contributors will be happy to share their stories and experience with newcomers.

  • There will be links to interactive self-passed instruqt scenarios shared during the event that help newcomers learn different aspects of development.

Where/when

Online on Matrix and Youtube. Tuesday, April 12, 2022, 12:00 - 20:00 UTC.

How to join
  • Add the event to your calendar. Use the ical URL (for example, in Google Calendar "Add other calendars" > "Import from URL") instead of importing the .ics file so that any updates to the event will be reflected in your calendar.

  • Check out the Summit page:

    • Add you name to attendees.
    • Suggest summit topics that would be interesting to you to hear about.
    • Vote on and propose changes to topics suggested by others.
    • If you want to be a presenter, please contact the Ansible Community team via [email protected].

We are looking forward to seeing you!:)

Add support for netcommon/gather_facts

Currently all the examples use this:

- name: Gather Facts
  gather_facts: no
  hosts: all

And require using the custom facts task from the collection. All the other main cisco platforms support netcommon. With the SMB collection if you do gather_facts: yes it grabs the facts from the host running the playbooks not the facts from the Cisco device. This is very confusing, is there a way to use gather_facts: yes with Cisco SMB?

SX550X-24F issue with parse_inventory

r'^NAME"(?P<name>[^"]+)"DESCR"(?P<descr>[^"]+)"PID"(?P<pid>[^"]+)"VID"(?P<vid>[^"]+)"SN"(?P<sn>\S+)\s*',

the regex in parse_inventory does not match on one of the lines produced by my switch, resulting in module failure since there is no error handling.

this is the raw output the switch:

switch-13#show inventory

NAME: "1"   DESCR: "SX550X-24F 24-Port 10G SFP+ Stackable Managed Switch"   
PID: SX550X-24F-K9   VID: V02   SN: DNI22500E5F   


NAME: "TenGigabitEthernet1/0/11"    DESCR: "SFP-10G-LR"    
PID: SFP-10G-LR    VID: V02     SN: CS101K63284         


NAME: "TenGigabitEthernet1/0/14"    DESCR: "SFP-10GBase-SR"    
PID: SFP-10G-SR    VID: V03     SN: CSG101KB2848        


NAME: "TenGigabitEthernet1/0/15"    DESCR: "SFP-10GBase-SR"    
PID: SFP-10G-SR    VID: V03     SN: CSSSRJC2101         


NAME: "TenGigabitEthernet1/0/16"    DESCR: "SFP-10GBase-SR"    
PID: SFP-10G-SR    VID: V03     SN: CSSSRJC2119         


NAME: "TenGigabitEthernet1/0/17"    DESCR: "SFP-10G-LR"    
PID: SFP-10G-LR    VID: V02     SN: CSS2003194730       


NAME: "TenGigabitEthernet1/0/18"    DESCR: "SFP-10G-LR"    
PID: SFP-10G-LR    VID: V02     SN: CSS2003194736       


NAME: "TenGigabitEthernet1/0/19"    DESCR: "SFP-10GBase-SR"    
PID: SFP-10G-SR    VID: V03     SN: CSSSRJC2093         


NAME: "TenGigabitEthernet1/0/20"    DESCR: "SFP-10GBase-SR"    
PID: SFP-10G-SR    VID: V03     SN: CSSSRJC2115         


NAME: "TenGigabitEthernet1/0/22"    DESCR: "Cisco SFP-10Gbase-CX1"    
PID: SFP-H10GB-CU3M    VID: V03     SN: MOC1906A079         


NAME: "TenGigabitEthernet1/0/23"    DESCR: "SFP-10G-LR"    
PID: SFP-10G-LR    VID: V02     SN: CSS2003194783       

                                                      
NAME: "TenGigabitEthernet1/0/24"    DESCR: "SFP-10G-LR"    
PID: SFP-10G-LR    VID: V02     SN: CSS2003194782       

switch-13#

this is what the data object looks like after the re.sub calls:

NAME: "1"   DESCR: "SX550X-24F 24-Port 10G SFP+ Stackable Managed Switch"     PID: SX550X-24F-K9   VID: V02   SN: DNI22500E5F   
NAME: "TenGigabitEthernet1/0/11"    DESCR: "SFP-10G-LR"      PID: SFP-10G-LR    VID: V02     SN: CS101K63284         
NAME: "TenGigabitEthernet1/0/14"    DESCR: "SFP-10GBase-SR"      PID: SFP-10G-SR    VID: V03     SN: CSG101KB2848        
NAME: "TenGigabitEthernet1/0/15"    DESCR: "SFP-10GBase-SR"      PID: SFP-10G-SR    VID: V03     SN: CSSSRJC2101         
NAME: "TenGigabitEthernet1/0/16"    DESCR: "SFP-10GBase-SR"      PID: SFP-10G-SR    VID: V03     SN: CSSSRJC2119         
NAME: "TenGigabitEthernet1/0/17"    DESCR: "SFP-10G-LR"      PID: SFP-10G-LR    VID: V02     SN: CSS2003194730       
NAME: "TenGigabitEthernet1/0/18"    DESCR: "SFP-10G-LR"      PID: SFP-10G-LR    VID: V02     SN: CSS2003194736       
NAME: "TenGigabitEthernet1/0/19"    DESCR: "SFP-10GBase-SR"      PID: SFP-10G-SR    VID: V03     SN: CSSSRJC2093         
NAME: "TenGigabitEthernet1/0/20"    DESCR: "SFP-10GBase-SR"    
PID: SFP-10G-SR    VID: V03     SN: CSSSRJC2115         
NAME: "TenGigabitEthernet1/0/22"    DESCR: "Cisco SFP-10Gbase-CX1"    
PID: SFP-H10GB-CU3M    VID: V03     SN: MOC1906A079         
NAME: "TenGigabitEthernet1/0/23"    DESCR: "SFP-10G-LR"    
PID: SFP-10G-LR    VID: V02     SN: CSS2003194783       
NAME: "TenGigabitEthernet1/0/24"    DESCR: "SFP-10G-LR"    
PID: SFP-10G-LR    VID: V02     SN: CSS2003194782

so after data.splitlines() one of the lines only contains NAME: "TenGigabitEthernet1/0/20" DESCR: "SFP-10GBase-SR" and the match object is None, resulting in AttributeError: 'NoneType' object has no attribute 'groupdict'

Not saving all running config

SUMMARY

While saving running config from cisco cbs350 it only saves first 15 lines as you know you have to press space to read all the config on cisco switches.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • community.ciscosmb
ANSIBLE VERSION
  config file = /home/ffabicevic/ansible_test/ansible.cfg
  configured module search path = ['/home/ffabicevic/.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.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
COLLECTION VERSION
CONFIGURATION

OS / ENVIRONMENT

Cisco CBS350-48P-PoE ios ver: 3.2.0.84

Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal

STEPS TO REPRODUCE

Just check your cfg file it only has 15 lines. Did you'r steps same as you everything goes well but the copied .cfg file is not complete.

  gather_facts: no
  hosts: all
  vars:
    - configs_dir: configs

  tasks:

    - name: Host info
      ansible.builtin.debug:
        verbosity: 3
        var: "hostvars"

    ###
    # Collect data
    #
    # - name: CiscoSMB - Gather Facts - subset default
    #  community.ciscosmb.facts:
    #    gather_subset:
    #      - default
      # when: ansible_network_os == 'community.ciscosmb.ciscosmb'

    - name: CiscoSMB - Gather Facts - subset config
      community.ciscosmb.facts:
        gather_subset:
          - config
            #      vars:
#        ansible_become: yes
#      # when: ansible_network_os == 'community.ciscosmb.ciscosmb'

    - name: CSV output
      ansible.builtin.debug:
        verbosity: 1
        msg:
          - "{{ ansible_facts['net_hostname'] }};{{ ansible_facts['net_model'] }};{{ ansible_facts['net_serialnum'] }};{{ ansible_facts['net_version'] }};{{ ansible_facts['net_hw_version'] }}"

    - name: Verbose output
      ansible.builtin.debug:
        verbosity: 2
        msg:
          - "Hostname:     {{ ansible_facts['net_hostname'] }}"
          - "Model:        {{ ansible_facts['net_model'] }}"
          - "SN:           {{ ansible_facts['net_serialnum'] }}"
          - "SW version    {{ ansible_facts['net_version'] }}"
          - "HW version:   {{ ansible_facts['net_hw_version'] }}"
          - "config:       {{ ansible_facts['net_config'] | default('') }}"

    - name: Create configuration directory
      local_action: file path={{ configs_dir }} state=directory
      run_once: true
      check_mode: no
      changed_when: no

    - name: Save running config
      local_action: copy content={{ ansible_net_config }} dest={{ configs_dir }}/{{ inventory_hostname }}_net_config

EXPECTED RESULTS

Whole running-config to be backuped.

ACTUAL RESULTS

The task completes.


Typo in /plugins/cliconf/ciscosmb.py

SUMMARY

Typo in /plugins/cliconf/ciscosmb.py at line 45, the command is 'show verison' instead of 'show version'

ISSUE TYPE
  • Bug Report
COMPONENT NAME

/plugins/cliconf/ciscosmb.py

ANSIBLE VERSION
ansible 2.10.8
  config file = /opt/ansible/ansible/audit/cisco/switch/audit/ansible.cfg
  configured module search path = ['/opt/ansible/.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.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
COLLECTION VERSION
Collection         Version
------------------ -------
community.ciscosmb 1.0.5  

ConnectionError

SUMMARY

Can't connect to switch

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Module send commands

ANSIBLE VERSION

ansible 2.9.27
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, Jun 28 2022, 15:30:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

COLLECTION VERSION

CONFIGURATION

ANSIBLE_SSH_ARGS(/etc/ansible/ansible.cfg) = -o StrictHostKeyChecking=accept-new

OS / ENVIRONMENT

SW version 1.4.9.4 ( date 03-Jun-2018 time 23:53:37 )
Boot version 1.4.0.02 ( date 24-Jun-2014 time 12:01:31 )

NAME: "1" DESCR: "SG500-28P 28-Port Gigabit PoE Stackable Managed Switch"

STEPS TO REPRODUCE

file hosts
[SWITCH-TEST-SG500]
10.127.5.136
[SWITCH-TEST-SG500:vars]
ansible_become_method=enable
ansible_become=true
ansible_network_cli_ssh_type=paramiko
ansible_connection=network_cli
ansible_network_os=community.ciscosmb.ciscosmb
ansible_user=user
ansible_password=password

file create_snmpv2_sg500.yml

  • name: Create SNMPv2 community for Cisco Small Business
    hosts: SWITCH-TEST-SG500
    gather_facts: false
    connection: local

    vars:
    community: xxxx

    tasks:

    • name: Create community "{{ community }}"
      community.ciscosmb.command:
      commands:
      - conf t
      - snmp-server community "{{ community }}" ro
ACTUAL RESULTS

WARNING: The below traceback may not be related to the actual failure.
File "/tmp/ansible_community.ciscosmb.command_payload_2l9h4j/ansible_community.ciscosmb.command_payload.zip/ansible_collections/community/ciscosmb/plugins/module_utils/ciscosmb.py", line 219, in get_capabilities
capabilities = Connection(module._socket_path).get_capabilities()
File "/tmp/ansible_community.ciscosmb.command_payload_2l9h4j/ansible_community.ciscosmb.command_payload.zip/ansible/module_utils/connection.py", line 190, in rpc
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [10.127.5.136]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"invocation": {
"module_args": {
"commands": [
"conf t",
"snmp-server community XXXX ro"
],
"interval": 1,
"match": "all",
"retries": 10,
"wait_for": null
}
},
"msg": "super() takes at least 1 argument (0 given)"

CBS350-24T-4G: "Failed to authenticate: Authentication failed."

SUMMARY

I have a "CBS350-24T-4G" which I'm trying to automate with Ansible. Authentication via ssh on the terminal works as expected, with password and with ssh-key. Trying to authenticate with ansible results in the error seen in the title.
My inventory looks like this:

all:
  children:
    network:
      hosts:
        cbs350.example.com:
          ansible_host: 192.168.1.1
          ansible_network_os: community.ciscosmb.ciscosmb
          ansible_connection: ansible.netcommon.network_cli
#          ansible_ssh_private_key_file: /home/user/.ssh/id_rsa
#          ansible_ssh_pass: **password**
          ansible_become_method: enable
          ansible_become_password: **password**
          ansible_become: true
          ansible_network_cli_ssh_type: paramiko

The playbook looks like this:

- gather_facts: no
  hosts: cbs350.example.com
  remote_user: "user"
  tasks:
    - name: "Create login banner"
      community.ciscosmb.command:
        commands: 
          - "banner login $"
          - "###############################"
          - "#  Authorized personal only!  #"
          - "###############################"
          - "$"

The log on the switch shows the following:

11-Nov-2022 17:10:56 :%AAA-W-REJECT: New ssh connection, source 192.168.1.100 destination 192.168.1.1  REJECTED
11-Nov-2022 17:10:56 :%AAA-W-REJECT: New ssh connection, source 192.168.1.100 destination 192.168.1.1  REJECTED
11-Nov-2022 17:10:56 :%AAA-W-REJECT: New ssh connection, source 192.168.1.100 destination 192.168.1.1  REJECTED

The debug logging on the switch doesn't yield any other information than this.

What is my issue here?

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.ciscosmb.command

ANSIBLE VERSION
ansible [core 2.13.6]
  config file = None
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0]
  jinja version = 3.0.3
  libyaml = True

COLLECTION VERSION
community.ciscosmb            1.0.5
CONFIGURATION
CALLBACKS_ENABLED(/home/user/Dokumente/Projects/ansible.cfg) = ['timer']
DEFAULT_HOST_LIST(/home/user/Dokumente/Projects/ansible.cfg) = ['/media/nfs/user/Projects/Ansible/Projects/inventory.yml']
DEFAULT_KEEP_REMOTE_FILES(env: ANSIBLE_KEEP_REMOTE_FILES) = True
DEFAULT_LOG_PATH(/home/user/Dokumente/Projects/ansible.cfg) = /media/nfs/user/Projects/Ansible/Projects/log/ansible.log
DEFAULT_ROLES_PATH(/home/user/Dokumente/Projects/ansible.cfg) = ['/media/nfs/user/Projects/Ansible/Projects/roles']

OS / ENVIRONMENT

Device: CBS350-24T-4G
Version: 3.0.0.69

STEPS TO REPRODUCE

see above

EXPECTED RESULTS

Successful connect

ACTUAL RESULTS
The full traceback is:
  File "/tmp/ansible_community.ciscosmb.command_payload_qty2t7_4/ansible_community.ciscosmb.command_payload.zip/ansible_collections/community/ciscosmb/plugins/module_utils/ciscosmb.py", line 219, in get_capabilities
    capabilities = Connection(module._socket_path).get_capabilities()
  File "/tmp/ansible_community.ciscosmb.command_payload_qty2t7_4/ansible_community.ciscosmb.command_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [cbs350.example.com]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "commands": [
                "banner login $",
                "###############################",
                "#  Authorized personal only!  #",
                "###############################",
                "$"
            ],
            "interval": 1,
            "match": "all",
            "retries": 10,
            "wait_for": null
        }
    },
    "msg": "Failed to authenticate: Authentication failed."
}

Possible to edit switch config

Hi,

Is it possible to edit configuration with the community.ciscosmb.command module? The stdout shows ' Unrecognized Command' On task set ntp. To me this looks like if the switch is not in enabled mode.
Is it possible to go into enable mode? If so, how?

inventory

[switches_smb]
sw-rzw-7555nb4-01 ansible_port=2222
sw-rzw-7412rv29-01 ansible_port=2222

[switches_smb:vars]
ansible_connection=network_cli
ansible_become=yes
ansible_become_method=enable
ansible_network_os=community.ciscosmb.ciscosmb
ansible_user=root
ansible_password=***
ansible_become_password=***

playbook

- name: "edit ntp config"
  hosts: switches_smb
  gather_facts: no
  tasks:
    - name: set ntp
      community.ciscosmb.command:
        commands: 
          - clock timezone CET +1
          - clock summer-time CET recurring last sun mar 02:00 last sun oct 03:00
          - clock source sntp
          - sntp unicast client enable
          - sntp unicast client poll
          - sntp server ntp1.root.nl poll
          - sntp server ntp2.root.nl poll
          - sntp server ntp3.root.nl poll
          - sntp source-interface vlan 10
    - name: show clock
      community.ciscosmb.command:
        commands: show clock
      register: output
    - name: show output
      debug: 
        var: output.stdout

Cisco CBS350 command Time-Out due to NO newline after command output

SUMMARY

When sending some specific commands to Cisco CBS350 the connection time's out.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Module send commands

ANSIBLE VERSION

ansible [core 2.15.1]
config file = .../ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /root/.local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /root/.local/bin/ansible
python version = 3.9.17 (main, Aug 9 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True

COLLECTION VERSION

community.ciscosmb 1.0.6

CONFIGURATION

[defaults]
use_persistent_connections = true
host_key_checking = false
timeout = 120
[persistent_connection]
command_timeout = 60

OS / ENVIRONMENT

Device: Cisco CBS350-24XTS
Version: 3.3.0.16

Name: paramiko
Version: 3.3.1

STEPS TO REPRODUCE

hosts:
[SWITCH-CBS350]
10.55.100.11
[SWITCH-CBS350:vars]
ansible_connection: network_cli
ansible_network_cli_ssh_type: paramiko
ansible_network_os: community.ciscosmb.ciscosmb

ansible_ssh_user: admin
ansible_ssh_password: pass12345

cisco-cbs.yml:

  • name: Cisco CBS
    hosts: SWITCH-CBS350
    gather_facts: false
    tasks:
    • name: Configure Cisco CBS
      community.ciscosmb.command:
      commands:
      - configure terminal
      - clock timezone EET 2 minutes 0
      - clock summer-time EET recurring eu
EXPECTED RESULTS

ansible-playbook cisco-cbs.yml

PLAY [Cisco CBS]

TASK [Configure Cisco CBS]
ok: [SWITCH-CBS350]

ACTUAL RESULTS

TASK [ Configure Cisco CBS]
fatal: [SWITCH-CBS350]: FAILED! => {"changed": false, "msg": "command timeout triggered, timeout value is 60 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."}

ADDITIONAL INFOS

The behavior from CLI.
Commands:
clock timezone EET 2 minutes 0
clock summer-time EET recurring eu

Output:
SWITCH-CBS350(config)#clock summer-time EET recurring eu
23-Mar-2023 14:59:17 %TIMEMANAGE-N-SMTIMEUPDATE: Summer-time updated: previous: None; new: begins Last Sun of Mar 01:00, ends Last Sun of Oct 01:00 offset 60 (acronym EET)
SWITCH-CBS350(config)#23-Mar-2023 14:59:17 %STCK SYSL-N-UNITTRP: UNIT ID 2,Trap:%TIMEMANAGE-N-SMTIMEUPDATE: Summer-time updated: previous: None; new: begins Last Sun of Mar 01:00, ends Last Sun of Oct 01:00 offset 60 (acronym EET)

(Note that the prompt "SWITCH-CBS350(config)#" is missing )

Output from a device (CBS220-24P-4G Version: 2.0.2.8) that doesn't experience this issue:
SWITCH-CBS350(config)#clock summer-time EET recurring eu
SWITCH-CBS350(config)#

(Note that the prompt "SWITCH-CBS350(config)#" is present )

Same goes for the clock timezone EET 2 minutes 0

Other commands that I have tested that don't have the issue of missing prompt are working.

When running these commands from SSH, an ENTER is needed in order to give other commands.

The first time the play runs, it applies the command and exists with time-out. If I run the play a second time it finishes successfully.

WORKAROUND

Modifying the "get" function defined in ../ansible_collections/community/ciscosmb/plugins/cliconf/ciscosmb.py " with "+ "\n"" for the command parameter fixes this issue.

Diff Exeample:

--- plugins/cliconf/ciscosmb.py.orig 2023-09-08 13:48:15
+++ plugins/cliconf/ciscosmb.py 2023-09-08 13:51:45
@@ -70,7 +70,7 @@
return
def get(self, command, prompt=None, answer=None, sendonly=False, newline=True, check_all=False):
-- return self.send_command(command=command, prompt=prompt, answer=answer, sendonly=sendonly, newline=newline, check_all=check_all)
++ return self.send_command(command=command + "\n", prompt=prompt, answer=answer, sendonly=sendonly, newline=newline, check_all=check_all)
def get_capabilities(self):
result = super().get_capabilities()

Also, setting "sendonly=TRUE" fixes this issue, but I did not find anyway of setting it directly from ansible.

Bad authentication

SUMMARY

Hi, i have the problem by using your module
My stdout:
ansible spb-expo-sw2-new -m community.ciscosmb.facts --vault-password-file ~/.vault_pass.txt --extra-vars "ANSIBLE_NET_USERNAME=****** ANSIBLE_NET_PASSWORD=*****" router | FAILED! => { "changed": false, "msg": "Failed to authenticate: Bad authentication type; allowed types: ['']" }
My vars file:
ansible_user: user; ansible_connection: network_cli; ansible_network_os: community.ciscosmb.ciscosmb; ansible_password: password;

Please help me with this issue
Regards

Finish getfacts

What to do:

  • default - sysinfo
  • config
  • hardware
  • interfaces
  • check correct function on stacks (ansible_net_stacked_models)

Links at bottom of readme don't work in Galaxy

SUMMARY

If I go to this collection today on galaxy and scroll down to the last sections, all three links are broken when I look at this inside Galaxy. They are currently relative links:
See [RELEASE_POLICY.md](./RELEASE_POLICY.md)
And should be absolute links instead.

ISSUE TYPE
  • Documentation Report
COMPONENT NAME
ANSIBLE VERSION

Action required: Add stable-2.13 to the test matrix

Dear maintainers,

According to the Collection requirements, collections included in the ansible package MUST run the ansible-test sanity command from the latest stable ansible-core branch.

It has been recently announced via the news-for-maintainers repository that the ansible-core stable-2.13 branch is available for testing.

  • Please add the stable-2.13 branch to your test matrix in the .github/workflows directory, at least, in the sanity jobs section. Any questions, just mention me here.

  • If you have integration and/or unit tests, please consider adding the branch to the corresponding sections too.

  • If you're not subscribed to the news-for-maintainers repository, please do it to avoid CI related issues in the future.

  • If the issue is not relevant to your collection, please close it.

Thank you!

Important information for collection maintainers

SUMMARY

Dear maintainers,

This is important for your collections!

  • In accordance with the Community decision, we have created the news-for-maintainers repository for announcements of changes impacting collection maintainers (see the examples) instead of Issue 45 that will be closed soon.

    • To keep yourself well-informed and, therefore, things in your collection working, please subscribe to the repository by using the Watch button in the upper right corner on the repository's home page.
    • If you do not want to get notifications about related discussions, please subscribe only to Issues.
    • Please read the brief guidelines on how the repository should be used.
    • Please avoid unnecessary discussions in issues, use the Discussions feature. Every comment posted will notify a lot of folks!
  • Also we would like to remind you about the Bullhorn contributor newsletter which has recently started to be released weekly. To learn what it looks like, see the past releases. Please subscribe and talk to the Community via Bullhorn!

  • Join us in #ansible-social (for news reporting & chat), #ansible-community (for discussing collection & maintainer topics), and other channels on Matrix/IRC.

  • Help the Community and the Steering Committee to make right decisions by taking part in discussing and voting on the Community Topics that impact the whole project and the collections in particular. Your opinion there will be much appreciated!

Thank you!

README Typo and misleading vars

Problem #1: There is a typo in the README.md file

Specifically, the typo is in the ciscosmb_gather_facts.yml playbook example, in the first task. The fully qualified module name specified is comunTity.ciscosmb.facts instead of community.ciscosmb.facts.
This made me think initially that there is something wrong with this module after copy-pasting the tasks to see if it works against my switches and being greeted by error messages.

Problem #2: The gather_facts variable specified in the inventory file is useless

Furthermore, I believe that setting gather_facts: no in the ciscosmb_inventory.yml file is misleading as it does pretty much nothing, at least according to my testing. If I specify the variable in my inventory without also setting gather_facts: false in the playbook itself, Ansible still attempts to gather facts.

For the record, I am running ansible version 2.11.7

mike@workstation:~$ ansible --version
ansible [core 2.11.7] 
    config file = /etc/ansible/ansible.cfg
    configured module search path = ['/home/mike/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
    ansible python module location = /usr/lib/python3/dist-packages/ansible
    ansible collection location = /home/mike/.ansible/collections:/usr/share/ansible/collections
    executable location = /usr/bin/ansible
    python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
    jinja version = 3.0.1
    libyaml = True

Working Example

Hello Petr

i want to congratulate you for creating this module.
I'm trying to use it in a playbook but till now without success.

This is the configuration i am using.
hosts

[cisco-smb]
CISCO-SF300-211 ansible_host=192.168.10.211

[cisco-smb:vars]
become=no
ansible_connection=network_cli
ansible_network_os=ios
ansible_user=cisco
ansible_password=XXXXXXX
ansible_become_pass=XXXXXXX

This is the playbook


  • hosts: cisco-smb
    vars_files:
    • ./vault/secrets.yaml
      tasks:
      • name: run show running-config on ciscosmb switches
        qaxi.ciscosmb.ciscosmb_facts:
        gather_subset:
        • config
          register: running_config
      • name: copy Running config to backup folder
        copy:
        content: "{{ running_config.stdout[0] }}"
        dest: "./backup/{{ inventory_hostname }}.txt"

This is the output of the playbook exec:

fatal: [CISCO-SF300-211]: FAILED! => {
"ansible_facts": {},
"changed": false,
"failed_modules": {
"ios_facts": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"exception": " File "/tmp/ansible_ios_facts_payload_yxvvh2vi/ansible_ios_facts_payload.zip/ansible/module_utils/network/common/network.py", line 229, in get_capabilities\n capabilities = Connection(module._socket_path).get_capabilities()\n File "/tmp/ansible_ios_facts_payload_yxvvh2vi/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py", line 185, in rpc\n raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)\n",
"failed": true,
"invocation": {
"module_args": {
"auth_pass": null,
"authorize": null,
"gather_network_resources": null,
"gather_subset": [
"all"
],
"host": null,
"password": null,
"port": null,
"provider": null,
"ssh_keyfile": null,
"timeout": null,
"username": null
}
},
"msg": "Failed to authenticate: Bad authentication type; allowed types: ['']"
}
},
"msg": "The following modules failed to execute: ios_facts\n"

Plase can you put a full working example in the docs.

Regards

Rewrite community.ciscosmb.ciscosmb_facts to community.ciscosmb.facts

SUMMARY

Rewrite community.ciscosmb.ciscosmb_facts to community.ciscosmb.facts
and Rewrite community.ciscosmb.ciscosmb_command to community.ciscosmb.command

ISSUE TYPE
  • community.ciscosmb.ciscosmb_facts is duplicating name ciscosmb
COMPONENT NAME
  • modules ciscosmb_command and ciscosmb_facts
ADDITIONAL INFORMATION
tasks:
    - name: CiscoSMB - Gather Facts - subset default
      # communtity.ciscosmb.ciscosmb_facts:
      communtity.ciscosmb.facts:
        gather_subset:
          - default

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.