Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #314/9c621be4 backport][stable-2] Fix ce_switchport module with connection type ansible.netcommon.netconf #370

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelogs/fragments/313_fix_broken_ce_switchport_module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bugfixes:
- community.network.ce_switchport - fix error causing by ``KeyError:`` ``host`` due to properties aren't
used anywhere (https://github.com/ansible-collections/community.network/issues/313)
24 changes: 5 additions & 19 deletions plugins/modules/network/cloudengine/ce_switchport.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
in the C(port trunk allow-pass vlan) command. Use verbose mode to see commands sent.
- When C(state=unconfigured), the interface will result with having a default Layer 2 interface, i.e. vlan 1 in access mode.
- This module requires the netconf system service be enabled on the remote device being managed.
- Recommended connection is C(netconf).
- This module also works with C(local) connections for legacy playbooks.
- Recommended connection is C(ansible.netcommon.netconf).
options:
interface:
description:
Expand Down Expand Up @@ -72,53 +71,45 @@
EXAMPLES = '''
- name: Switchport module test
hosts: cloudengine
connection: local
gather_facts: no
vars:
cli:
host: "{{ inventory_hostname }}"
port: "{{ ansible_ssh_port }}"
username: "{{ username }}"
password: "{{ password }}"
transport: cli
ansible_user: root
ansible_password: PASSWORD
ansible_connection: ansible.netcommon.netconf
ansible_network_os: community.network.ce

tasks:
- name: Ensure 10GE1/0/22 is in its default switchport state
community.network.ce_switchport:
interface: 10GE1/0/22
state: unconfigured
provider: '{{ cli }}'

- name: Ensure 10GE1/0/22 is configured for access vlan 20
community.network.ce_switchport:
interface: 10GE1/0/22
mode: access
default_vlan: 20
provider: '{{ cli }}'

- name: Ensure 10GE1/0/22 only has vlans 5-10 as trunk vlans
community.network.ce_switchport:
interface: 10GE1/0/22
mode: trunk
pvid_vlan: 10
trunk_vlans: 5-10
provider: '{{ cli }}'

- name: Ensure 10GE1/0/22 is a trunk port and ensure 2-50 are being tagged (doesn't mean others aren't also being tagged)
community.network.ce_switchport:
interface: 10GE1/0/22
mode: trunk
pvid_vlan: 10
trunk_vlans: 2-50
provider: '{{ cli }}'

- name: Ensure these VLANs are not being tagged on the trunk
community.network.ce_switchport:
interface: 10GE1/0/22
mode: trunk
trunk_vlans: 51-4000
state: absent
provider: '{{ cli }}'
'''

RETURN = '''
Expand Down Expand Up @@ -334,11 +325,6 @@ def __init__(self, argument_spec):
self.untagged_vlans = self.module.params['untagged_vlans']
self.tagged_vlans = self.module.params['tagged_vlans']

# host info
self.host = self.module.params['host']
self.username = self.module.params['username']
self.port = self.module.params['port']

# state
self.changed = False
self.updates_cmd = list()
Expand Down