kayobe/ansible/physical-network.yml
Mark Goddard 920d9e0eee Add Dell PowerConnect switch support
PowerConnect switches do not support the dellos Ansible modules, since
they are based on DellOS version 4. This role uses the expect module to
perform simple switch configuration.

Change-Id: Icb59aaff75f9faf089423610fecb06598f75e35e
Story: 2002106
Task: 19784
2018-06-22 15:12:29 +01:00

108 lines
4.2 KiB
YAML

---
# Switch configuration depends on the type of switch, so groups hosts by their
# switch type and apply tasks/roles to the relevant groups.
- name: Group hosts by their switch type and apply configuration filters
hosts: switches
gather_facts: no
vars:
# Set this variable to True to configure the network for hardware
# discovery.
physical_network_enable_discovery: False
# Set this variable to a comma-separated list of names of interfaces to
# configure in order to restrict configuration to a subset of interfaces.
physical_network_interface_limit: ''
# Set this variable to a comma-separated list of descriptions of interfaces
# to configure in order to restrict configuration to a subset of
# interfaces.
physical_network_interface_description_limit: ''
# Set this variable to True in order to display the candidate switch
# configuration and exit without applying it.
physical_network_display: False
tasks:
- name: Fail if both interface name and description limits are specified
fail:
msg: >
The interface name and interface description limits are mutually
exclusive.
when:
- physical_network_interface_limit != ''
- physical_network_interface_description_limit != ''
- name: Group hosts by their switch type
group_by:
key: "switches_of_type_{{ switch_type }}"
- name: Group hosts by whether display mode is set
group_by:
key: "switches_in_display_mode_{{ physical_network_display | bool }}"
- name: Add discovery interface configuration when performing discovery
set_fact:
switch_interface_config: >
{{ switch_interface_config | combine(switch_interface_config_discovery) }}
when: physical_network_enable_discovery | bool
- name: Restrict switch interfaces to requested subset by name
set_fact:
switch_interface_config: >
{{ switch_interface_config |
switch_interface_config_select_name(physical_network_interface_limit.split(",")) }}
when: physical_network_interface_limit != ''
- name: Restrict switch interfaces to requested subset by description
set_fact:
switch_interface_config: >
{{ switch_interface_config |
switch_interface_config_select_description(physical_network_interface_description_limit.split(",")) }}
when: physical_network_interface_description_limit != ''
- name: Display switch configuration
hosts: switches_in_display_mode_True
gather_facts: no
tasks:
- name: Display the candidate global switch configuration
debug:
var: switch_config
- name: Display the candidate switch interface configuration
debug:
var: switch_interface_config
- name: Ensure DellOS physical switches are configured
hosts: switches_of_type_dellos6:switches_of_type_dellos9:&switches_in_display_mode_False
gather_facts: no
roles:
- role: ssh-known-host
- role: dell-switch
dell_switch_type: "{{ switch_type }}"
dell_switch_provider: "{{ switch_dellos_provider }}"
dell_switch_config: "{{ switch_config }}"
dell_switch_interface_config: "{{ switch_interface_config }}"
- name: Ensure Dell PowerConnect physical switches are configured
hosts: switches_of_type_dell-powerconnect:&switches_in_display_mode_False
gather_facts: no
roles:
- role: ssh-known-host
- role: stackhpc.dell-powerconnect-switch
dell_powerconnect_switch_type: "{{ switch_type }}"
dell_powerconnect_switch_provider: "{{ switch_dell_powerconnect_provider }}"
dell_powerconnect_switch_config: "{{ switch_config }}"
dell_powerconnect_switch_interface_config: "{{ switch_interface_config }}"
- name: Ensure Juniper physical switches are configured
hosts: switches_of_type_junos:&switches_in_display_mode_False
gather_facts: no
roles:
- role: ssh-known-host
- role: junos-switch
junos_switch_type: "{{ switch_type }}"
junos_switch_provider: "{{ switch_junos_provider }}"
junos_switch_config_format: "{{ switch_junos_config_format }}"
junos_switch_config: "{{ switch_config }}"
junos_switch_interface_config: "{{ switch_interface_config }}"