78 lines
2.2 KiB
Plaintext
78 lines
2.2 KiB
Plaintext
**** start of template ****
|
|
|
|
0) display the config_context:
|
|
|
|
top level context item:
|
|
|
|
{'best_unicorn': ['sugar socks', 'star light', 'sparkle', 'twinkle', 'glitter love'], 'cbeebies_schedule': '18/11/2023', 'device': 'device_b', 'gabbys_doll_house': 1, 'harry_potter': 1, 'octonaughts': 1, 'region': 'europe', 'site': 'dublin'}
|
|
|
|
selecting the best unicorn with config_context['best_unicorn'][0]:
|
|
|
|
sugar socks
|
|
|
|
accessing a key pair injected into the jinja environment global variables:
|
|
(in this case the config_context printed out in human readable yaml format)
|
|
|
|
best_unicorn:
|
|
- sugar socks
|
|
- star light
|
|
- sparkle
|
|
- twinkle
|
|
- glitter love
|
|
cbeebies_schedule: 18/11/2023
|
|
device: device_b
|
|
gabbys_doll_house: 1
|
|
harry_potter: 1
|
|
octonaughts: 1
|
|
region: europe
|
|
site: dublin
|
|
|
|
|
|
loop through the config_context variable in jinja:
|
|
|
|
best_unicorn:['sugar socks', 'star light', 'sparkle', 'twinkle', 'glitter love']
|
|
cbeebies_schedule:18/11/2023
|
|
device:device_b
|
|
gabbys_doll_house:1
|
|
harry_potter:1
|
|
octonaughts:1
|
|
region:europe
|
|
site:dublin
|
|
|
|
1) source template ./device/device_b.yml
|
|
|
|
2) source template ./device/region/europe.yml
|
|
|
|
3) source template ./device/site/dublin.yml
|
|
|
|
4) source template ./device/role/<files>.yml
|
|
these contexts happens to be a list in the inventory
|
|
files under this directory happen to have the same weight(they dont have to)
|
|
thus these files do not have the same keys as they would clash
|
|
|
|
gabbys_doll_house = 1
|
|
|
|
octonaughts = 1
|
|
|
|
notice best_unicorn is in the all.yml context and router.yml context
|
|
router.yml has a higher precedence(lower weight value)
|
|
|
|
- sugar socks
|
|
- star light
|
|
- sparkle
|
|
- twinkle
|
|
- glitter love
|
|
|
|
harry_potter = 1
|
|
|
|
notice cbeebies_schedule is in the all.yml context and vpn.yml context
|
|
all.yml context is weighted last/-1, any other context will overwrite it
|
|
vpn.yml has a higher precedence(lower weight value)
|
|
|
|
cbeebies_schedule = 18/11/2023
|
|
|
|
4) source template ./device/role/all.yml
|
|
nothing is rendered using this context, all variables are overwritten by contexts with higher precedence
|
|
this would be a good place to put service accounts in ACLs or legal disclaimers
|
|
|
|
**** end of template **** |