Fix handling of switch_type variable in Ansible 2.5

In Ansible, playbook group variables take precedence over inventory
group variables. Typically in a kayobe-config we might specify the
switch_type variable for a group containing switches using inventory
group_vars. This seemed to work in Ansible 2.3, but since Ansible 2.4
the default value of None in kayobe's playbook group_vars takes
precedence. This behaviour is as documented, not sure why it worked
previously.

This change removes the default value of None set in the playbook
group_vars.

Change-Id: I042ad8d115cdc0dd57a116e1be9d397ef4d216ae
Story: 2002903
Task: 22870
This commit is contained in:
Mark Goddard 2018-07-09 15:30:44 +01:00
parent bb28786069
commit c175b078e5
2 changed files with 14 additions and 7 deletions

View File

@ -1,7 +0,0 @@
---
###############################################################################
# Switch type configuration.
# This configures the type of switch, which is used to determine how the switch
# will be configured.
switch_type:

View File

@ -19,6 +19,12 @@
# Set this variable to True in order to display the candidate switch
# configuration and exit without applying it.
physical_network_display: False
# List of supported values for the 'switch_type' variable.
supported_switch_types:
- dell
- dell-powerconnect
- junos
- mellanox
tasks:
- name: Fail if both interface name and description limits are specified
fail:
@ -29,6 +35,14 @@
- physical_network_interface_limit != ''
- physical_network_interface_description_limit != ''
- name: Fail if the switch type is not defined
fail:
msg: >
The switch type is not defined or is unrecognised. Configure the type
of each host in the 'switches' group via the 'switch_type' variable.
when: switch_type is not defined or
switch_type not in supported_switch_types
- name: Group hosts by their switch type
group_by:
key: "switches_of_type_{{ switch_type }}"