gc_integration_templater/rendered_templates/device_b.txt

78 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2023-11-20 12:34:46 +00:00
**** start of template ****
0) display the config_context:
top level context item:
2023-12-21 17:29:43 +00:00
{'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'}
2023-11-20 12:34:46 +00:00
selecting the best unicorn with config_context['best_unicorn'][0]:
2023-12-21 17:29:43 +00:00
sugar socks
2023-11-20 12:34:46 +00:00
accessing a key pair injected into the jinja environment global variables:
(in this case the config_context printed out in human readable yaml format)
2023-12-21 17:29:43 +00:00
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
2023-11-20 12:34:46 +00:00
loop through the config_context variable in jinja:
2023-12-21 17:29:43 +00:00
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
2023-11-20 12:34:46 +00:00
2023-12-21 17:29:43 +00:00
1) source template ./device/device_b.yml
2023-11-20 12:34:46 +00:00
2023-12-21 17:29:43 +00:00
2) source template ./device/region/europe.yml
2023-11-20 12:34:46 +00:00
2023-12-21 17:29:43 +00:00
3) source template ./device/site/dublin.yml
2023-11-20 12:34:46 +00:00
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
2023-12-21 17:29:43 +00:00
gabbys_doll_house = 1
2023-11-20 12:34:46 +00:00
2023-12-21 17:29:43 +00:00
octonaughts = 1
2023-11-20 12:34:46 +00:00
notice best_unicorn is in the all.yml context and router.yml context
router.yml has a higher precedence(lower weight value)
2023-12-21 17:29:43 +00:00
- sugar socks
- star light
- sparkle
- twinkle
- glitter love
2023-11-20 12:34:46 +00:00
2023-12-21 17:29:43 +00:00
harry_potter = 1
2023-11-20 12:34:46 +00:00
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)
2023-12-21 17:29:43 +00:00
cbeebies_schedule = 18/11/2023
2023-11-20 12:34:46 +00:00
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 ****