Skip to content

Instantly share code, notes, and snippets.

@ppmathis
Created December 29, 2016 16:56
Show Gist options
  • Select an option

  • Save ppmathis/dead01276606a45982f88088982b3125 to your computer and use it in GitHub Desktop.

Select an option

Save ppmathis/dead01276606a45982f88088982b3125 to your computer and use it in GitHub Desktop.
location-mappings:
octopus.ssx.li: zrh1
location-overrides@zrh1:
ssx-resolvconf:
servers: [4.3.2.1]
[email protected]:
ssx-resolvconf:
servers: [1.3.3.7, 4.4.8.8]
base:
'*':
- common
- overrides
{% import_yaml tpldir + '/variables.yml' as vars %}
{% set data = vars.get('defaults', {}) %}
{% set _location = salt['pillar.get']('location-mappings:' + grains['fqdn'], None) %}
{% do data.update(salt['pillar.get'](sls, {})) %}
{% if _location is not none %}{% do data.update(salt['pillar.get']('location-overrides@' + _location + ':' + sls, {})) %}{% endif %}
{% do data.update(salt['pillar.get']('host-overrides@' + grains['fqdn'] + ':' + sls, {})) %}
{% do data.update({ 'maps': {
'os_family': salt['grains.filter_by'](vars.os_family, base='default', grain='os_family', merge=salt['pillar.get'](sls + ':lookup', {}))
}}) %}
{% if data.maps.os_family is none %}{{ salt.test.exception('No suitable os_family mapping found for: ' + grains['os_family']) }}{% endif %}
{% from 'map.jinja' import data with context %}
ssx-resolvconf:
cmd.run:
- name: echo {{ data.servers }} {{ data.maps.os_family.config }}
defaults:
domains: ssx.li
servers:
- 8.8.8.8
- 8.8.4.4
os_family:
Debian:
config: /etc/resolv.conf
CentOS:
config: /etc/resolv.lolcat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment