Skip to content

Instantly share code, notes, and snippets.

@iggy
Created April 16, 2015 22:42
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 iggy/93c65ca26ea6c7eff144 to your computer and use it in GitHub Desktop.
Save iggy/93c65ca26ea6c7eff144 to your computer and use it in GitHub Desktop.
dict merging hurts my eyes
{% import_yaml "mongodb/defaults.yaml" as defaults %}
{% import_yaml "mongodb/osmap.yaml" as osmap %}
{% import_yaml "mongodb/codenamemap.yaml" as codemap %}
{# get the settings for the os_family grain #}
{% set osfam = salt['grains.filter_by'](osmap) %}
{# get the settings for the oscodename grain, os_family data will override
oscodename data #}
{% set oscode = salt['grains.filter_by'](codemap,
grain='oscodename',
merge=osfam) %}
{# merge the os family/codename specific data over the defaults #}
{% do defaults.mongodb.update(oscode) %}
{# merge the pillar:lookup dict into the defaults/os specific dict #}
{% set lookup = salt['pillar.get']('mongodb:lookup', default=defaults.mongodb, merge=True) %}
{# merge the actual mongodb pillar into the above combined dict #}
{% set mdb = salt['pillar.get']('mongodb', default=lookup, merge=True) %}
{# this hopefully goes away soon #}
{% set ms = salt['pillar.get']('mongos', default=defaults.mongos, merge=True) %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment