Skip to content

Instantly share code, notes, and snippets.

@ryanwalder
Created January 24, 2018 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanwalder/c33545a2f2c7d42724a16d762c44c22f to your computer and use it in GitHub Desktop.
Save ryanwalder/c33545a2f2c7d42724a16d762c44c22f to your computer and use it in GitHub Desktop.
# Get full minion id, should be fqdn
{%- set id = salt.grains.get('id') %}
# Get the hostname
{%- set sid = id.split('.')[0] %}
# Break down the hostname into the chunks we need to generate the pillar
# folder structure
{%- set use = sid[0:3] %} # use: not used within pillar ATM
{%- set platform = sid[3:6] %} # platform
{%- set component = sid[6:9] %} # component
{%- set os = sid[8] %} # os
{%- set number = sid[9:10] %} # number
{%- set env = sid[11] %} # environment
# Get the full domain
{%- set domain = id.split('.')[1:]|join('.') %}
# List of all environments, used for applying anti environment pillar
{%- set environments = ['v', 'd', 'q', 's', 'p', 'c'] %}
# Checks if a file exists in the following places:
# global/init.sls
# global/virtual/init.sls
# global/os/os/init.sls
# global/os/os/family/init.sls
# global/os/os/family/release/init.sls
# global/environment/env/init.sls
# global/environment/env/anti.sls
# global/component/init.sls
# platform/init.sls
# platform/environment/init.sls
# platform/environment/anti.sls
# platform/component/init.sls
# platform/component/environment/init.sls
# platform/component/environment/anti.sls
# platform/component/environment/number/init.sls
# NOTE: Ordering of the file lookups below is very important!
# If you define the same pillar keypairs in multiple files the last loaded wins
# This allows defaults to be set higher up with per component, platform, and env overrides
# Due to the file_exists checks below we can't use gitfs for pillar
# The other way around this would be blank init.sls files in every possible
# location which is way too messy.
base:
'*':
# Pillar for everything
- global
- global.virt.{{ salt.grains.get('virtual')|lower }}
- global.os.{{ salt.grains.get('os_family')|lower }}
- global.os.{{ salt.grains.get('os_family')|lower }}.{{ salt.grains.get('oscodename')|lower }}
- global.environment.{{ env }}
- global.environment.{{ env }}.anti
- global.tech.{{ component }}
- {{ platform }}
- {{ platform }}.{{ env }}
- {{ platform }}.{{ env }}.anti
- {{ platform }}.{{ component }}
- {{ platform }}.{{ component }}.{{ env }}
- {{ platform }}.{{ component }}.{{ env }}.anti
- {{ platform }}.{{ component }}.{{ env }}.{{ number }}
- ignore_missing: True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment