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

Ansible8 fixes #13

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dell_powerconnect_switch_provider:
dell_powerconnect_switch_config: []

# Interface configuration. Dict mapping switch interface names to configuration
# dicts. Each dict contains a 'description' (or 'name' in case of vlans) item and
# dicts. Each dict contains a 'description' (or 'name' in case of vlans) item and
# a 'config' item which should contain a list of per-interface configuration.
dell_powerconnect_switch_interface_config: {}

Expand Down
7 changes: 4 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
---
galaxy_info:
#role_name: dell_powerconnect_switch
role_name: dell_powerconnect_switch
grzegorzkoper marked this conversation as resolved.
Show resolved Hide resolved
namespace: stackhpc
author: Mark Goddard
description: >
Role to configure Dell PowerConnect switches
company: StackHPC Ltd
license: Apache2
min_ansible_version: 2.0
min_ansible_version: "2.0"
platforms:
- name: EL
versions:
- 7
- all
galaxy_tags:
- networking
- dell
Expand Down
27 changes: 13 additions & 14 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
# Need to use pip since the CentOS provided package is too old for Ansible.
- name: Ensure the pexpect Python package is installed
local_action:
module: pip
delegate_to: localhost
ansible.builtin.pip:
name: pexpect
state: present
become: true

- name: Ensure global switch configuration is applied
local_action:
module: expect
delegate_to: localhost
ansible.builtin.expect:
command: "ssh {{ ansible_ssh_common_args | default }} {{ dell_powerconnect_switch_provider.username }}@{{ dell_powerconnect_switch_provider.host }}"
responses: >-
{{ dell_powerconnect_auth_responses |
Expand All @@ -30,8 +30,8 @@
config_responses: "{{ {dell_powerconnect_config_prompt: dell_powerconnect_switch_config + ['exit']} }}"

- name: Ensure switch interface configuration is applied
local_action:
module: expect
delegate_to: localhost
ansible.builtin.expect:
command: "ssh {{ ansible_ssh_common_args | default }} {{ dell_powerconnect_switch_provider.username }}@{{ dell_powerconnect_switch_provider.host }}"
responses: >-
{{ dell_powerconnect_auth_responses |
Expand Down Expand Up @@ -60,15 +60,14 @@
item.value.config | default([]) +
['exit', 'exit']} }}
loop_control:
label:
interface: "{{ item.key }}"
description: "{{ item.value.description | default('<none>') }}"
name: "{{ item.value.name | default('<none>') }}"
config: "{{ item.value.config | default([]) }}"

label: |
"{'interface': '{{ item.key }}',
'description': '{{ item.value.description | default('<none>') }}',
'name': '{{ item.value.name | default('<none>') }}',
'config': '{{ item.value.config | default([]) }}'}"
- name: Write running configuration to startup configuration
local_action:
module: expect
delegate_to: localhost
ansible.builtin.expect:
command: "ssh {{ ansible_ssh_common_args | default }} {{ dell_powerconnect_switch_provider.username }}@{{ dell_powerconnect_switch_provider.host }}"
responses: >-
{{ dell_powerconnect_auth_responses |
Expand Down