forked from bluebanquise/bluebanquise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bluebanquise_core.ini
86 lines (66 loc) · 5.1 KB
/
bluebanquise_core.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# BlueBanquise core and logic variables.
# Append your inventory definition in first par of this file.
# DO NOT EDIT J2_ LOGIC section of the file. Precedence it.
# Refer to BlueBanquise documentation for details.
######################### DEFINE YOUR INVENTORY HERE #########################
######################### DO NOT EDIT ABOVE THIS POINT #########################
# These values can be precedenced to change roles logic and adapt to any needs.
# j2_ variables centralize core logic of BlueBanquise roles, feel free to
# abuse of them.
# In theory, these variables are crash free, and will return none if any error or not found.
# Please report any crash.
[all:vars]
# bb_icebergs_system=false
# bb_iceberg_hosts_range:
#############################################################
############ CORE REGEX
#####
bb_core_iceberg_naming=iceberg
bb_core_equipment_naming=equipment
bb_core_management_networks_naming=net
bb_core_master_groups_naming=mg
bb_core_managements_group_name=mg_managements
#############################################################
############ J2_ LOGIC
#####
### Groups
# List of master groups.
j2_master_groups_list="{{ groups | select('match','^'+bb_core_master_groups_naming+'_.*') | list | unique | sort }}"
# List of equipment groups.
j2_equipment_groups_list="{{ (groups | select('match','^'+bb_core_equipment_naming+'_.*') | list | length | int > 0) | ternary(groups | select('match','^'+bb_core_equipment_naming+'_.*') | list | unique | sort, ['all']) }}"
# Host current equipment group.
j2_node_equipment="{{ (groups | select('match','^'+bb_core_equipment_naming+'_.*') | list | length | int > 0) | ternary(group_names | select('match','^'+bb_core_equipment_naming+'_.*') | list | unique | sort | first | default('') | replace(bb_core_equipment_naming + '_',''), 'all') }}"
### Network
## Resolution
# Resolution network. The network on which host can be ping by direct name. (ex=ping c001).
j2_node_main_resolution_network="{{ network_interfaces[0].network | default(none) }}"
# Resolution address.
j2_node_main_resolution_address="{{ (network_interfaces[0].ip4 | default('')).split('/')[0] | default(none) }}"
## Main network
# The network used by Ansible to deploy configuration (related to ssh).
# Also the network used by the host to get services ip.
j2_node_main_network="{{ network_interfaces | default([]) | selectattr('network','defined') | selectattr('network','match','^'+j2_current_iceberg_network+'-[a-zA-Z0-9]+') | map(attribute='network') | list | first | default(none) }}"
# Main network interface. For consistency, we use j2_node_main_network as source.
j2_node_main_network_interface="{{ network_interfaces[j2_node_main_network].interface | default(none) }}"
# Main address, same concept.
j2_node_main_address="{{ network_interfaces[j2_node_main_network].ip4 | default(none) }}"
## Other
# List of management networks.
j2_management_networks="{{ networks | select('match','^'+j2_current_iceberg_network+'-[a-zA-Z0-9]+') | list | unique | sort }}"
### Icebergs engine file
# List all icebergs
j2_icebergs_groups_list="{{ groups | select('match','^'+bb_core_iceberg_naming+'[a-zA-Z0-9]+') | list }}"
# Get total number of icebergs
j2_number_of_icebergs="{{ groups | select('match','^'+bb_core_iceberg_naming+'[a-zA-Z0-9]+') | list | length }}"
# Grab current iceberg group
j2_current_iceberg="{{ bb_icebergs_system | default(false) | ternary( group_names | select('match','^'+bb_core_iceberg_naming+'[a-zA-Z0-9]+') | list | unique | sort | first | default(bb_core_iceberg_naming+'1'), bb_core_iceberg_naming+'1') }}"
# Grab current iceberg number
j2_current_iceberg_number="{{ j2_current_iceberg | replace(bb_core_iceberg_naming,' ') | trim }}"
# Grab current iceberg networks pattern
j2_current_iceberg_network="{{ bb_icebergs_system | default(false) | ternary(bb_core_management_networks_naming + (j2_current_iceberg_number | string), bb_core_management_networks_naming) }}"
# Generate list of managements connected to this iceberg from sub icebergs
j2_iceberg_sub_managements_members="{% set range = [] %}{% for host in (groups[bb_core_managements_group_name] | default([])) %}{% if (hostvars[host]['bb_iceberg_master'] | default(none)) == j2_current_iceberg %}{{ range.append(host) }}{% endif %}{% endfor %}{{ range }}"
# Generate range of hosts to include in current configurations
j2_hosts_range="{{ ((bb_icebergs_system | default(false)) == true and (bb_iceberg_hosts_range | default('all')) == 'iceberg') | ternary( j2_iceberg_sub_managements_members + groups[j2_current_iceberg] | default([]), groups['all']) }}"
# Generate a dict that contains host main network for each iceberg
j2_icebergs_main_network_dict="{{ '{' }}{% for iceberg in (j2_icebergs_groups_list | default([])) %}{% if not loop.first %},{% endif %}'{{ iceberg }}':'{{ network_interfaces | default([]) | selectattr('network', 'defined') | selectattr('network', 'match', '^'+(bb_icebergs_system | default(false) | ternary(bb_core_management_networks_naming + (iceberg | replace(bb_core_iceberg_naming, ' ') | trim | string), bb_core_management_networks_naming) )+'-[a-zA-Z0-9]+') | map(attribute='network') | list | first | default(none) }}'{% endfor %}{{ '}' }}"