I'm working on modeling our datacenter top-of-rack switches in Ansible, and have run into a potential problem with my approach. The basic idea is to use a hierarchal group structure that starts with general purpose (tor), and then get more specific for each deployment based on application that rack is supporting:
[tors]
[app1switches]
app1switch1
app1switch2
[app2switches]
app2switch1
app2switch2
[tors:children]
app1switches
app2switches
I want to abstract all my VLAN configuration into group-defined variables. In this example, let's say that there is at least one VLAN that is standard across all TORs, and then each application has their own unique set of VLANs that also need to be applied. My idea was to create group variable files such as:
#
# tors
#
---
vlans:
- name: GLOBAL-VLAN
id: 100
net: "{{ globalvlan_prefix }}"
#
# app1switches
#
---
vlans:
- name: SPECIAL-APP1-VLAN
id: 110
net: "{{ app1_prefix }}"
#
# app2switches
#
---
vlans:
- name: SPECIAL-APP2-VLAN
id: 120
net: "{{ app2_prefix }}"
Ultimately the goal is for any device that is a member of the app1switches group to get both SPECIAL-APP1-VLAN + GLOBAL-VLAN, while app2switches would get SPECIAL-APP2-VLAN + GLOBAL-VLAN. The problem is, the more specific group variable is over-riding the more generic so I am only applying the special app vlans.
Is there a way to define these list variables in an cumulative way, such that the end-result of the 'vlans' variable is a 2 item list?
--
Cody