2
0

Merge pull request #106 from iggy/cleanup_variable_overwriting

Don't overwrite salt variable
This commit is contained in:
Forrest 2015-03-17 15:27:00 -07:00
commit 611e78eb4d
9 changed files with 111 additions and 98 deletions

View File

@ -1,14 +1,14 @@
{% from "salt/map.jinja" import salt with context %} {% from "salt/map.jinja" import salt_settings with context %}
include: include:
- salt.master - salt.master
salt-api: salt-api:
pkg.installed: pkg.installed:
- name: {{ salt['salt-api'] }} - name: {{ salt_settings.salt_api }}
service.running: service.running:
- name: {{ salt.get('api-service', 'salt-api') }} - name: {{ salt_settings.api_service }}
- require: - require:
- service: {{ salt.get('api-service', 'salt-master') }} - service: {{ salt_settings.api_service }}
- watch: - watch:
- pkg: salt-master - pkg: salt-master

View File

@ -1,6 +1,4 @@
{% from "salt/map.jinja" import salt with context %} {% from "salt/map.jinja" import salt_settings with context %}
{% do salt.update(pillar.get('salt', {})) -%}
{% set cloud = salt.get('cloud', {}) -%}
python-pip: python-pip:
pkg.installed pkg.installed
@ -24,7 +22,7 @@ apache-libcloud:
salt-cloud: salt-cloud:
pkg.installed: pkg.installed:
- name: {{ salt['salt-cloud'] }} - name: {{ salt_settings.salt_cloud }}
- require: - require:
- pip: apache-libcloud - pip: apache-libcloud
- pip: pycrypto - pip: pycrypto
@ -32,7 +30,7 @@ salt-cloud:
- pip: crypto - pip: crypto
{% endif %} {% endif %}
{% for folder in cloud['folders'] %} {% for folder in salt_settings.cloud.folders %}
{{ folder }}: {{ folder }}:
file.directory: file.directory:
- name: /etc/salt/{{ folder }} - name: /etc/salt/{{ folder }}
@ -43,7 +41,7 @@ salt-cloud:
- makedirs: True - makedirs: True
{% endfor %} {% endfor %}
{% for cert in pillar.get('salt_cloud_certs', {}) %} {% for cert in salt_settings.salt_cloud_certs %}
{% for type in ['pem'] %} {% for type in ['pem'] %}
cloud-cert-{{ cert }}-pem: cloud-cert-{{ cert }}-pem:
file.managed: file.managed:
@ -59,23 +57,19 @@ cloud-cert-{{ cert }}-pem:
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% for providers in cloud['providers'] %} {% for providers in salt_settings.cloud.providers %}
salt-cloud-profiles-{{ providers }}: salt-cloud-profiles-{{ providers }}:
file.managed: file.managed:
- name: /etc/salt/cloud.profiles.d/{{ providers }}.conf - name: /etc/salt/cloud.profiles.d/{{ providers }}.conf
- template: jinja - template: jinja
- source: salt://salt/files/cloud.profiles.d/{{ providers }}.conf - source: salt://salt/files/cloud.profiles.d/{{ providers }}.conf
{% endfor %}
{% for providers in cloud['providers'] %}
salt-cloud-providers-{{ providers }}: salt-cloud-providers-{{ providers }}:
file.managed: file.managed:
- name: /etc/salt/cloud.providers.d/{{ providers }}.conf - name: /etc/salt/cloud.providers.d/{{ providers }}.conf
- template: jinja - template: jinja
- source: salt://salt/files/cloud.providers.d/{{ providers }}.conf - source: salt://salt/files/cloud.providers.d/{{ providers }}.conf
{% endfor %}
{% for providers in cloud['providers'] %}
salt-cloud-maps-{{ providers }}: salt-cloud-maps-{{ providers }}:
file.managed: file.managed:
- name: /etc/salt/cloud.maps.d/{{ providers }}.conf - name: /etc/salt/cloud.maps.d/{{ providers }}.conf

12
salt/defaults.yaml Normal file
View File

@ -0,0 +1,12 @@
salt:
config_path: /etc/salt
minion_service: salt-minion
master_service: salt-master
api_service: salt-api
syndic_service: salt-syndic
salt_master: salt-master
salt_minion: salt-minion
salt_syndic: salt-syndic
salt_cloud: salt-cloud
salt_api: salt-api
salt_ssh: salt-ssh

View File

@ -1,65 +1,72 @@
{% set salt = salt['grains.filter_by']({ {% import_yaml "salt/defaults.yaml" as default_settings %}
'Debian': {'salt-master': 'salt-master',
'salt-minion': 'salt-minion', {% set distro_map = salt['grains.filter_by']({
'salt-syndic': 'salt-syndic', 'Debian': {'salt_master': 'salt-master',
'salt-cloud': 'salt-cloud', 'salt_minion': 'salt-minion',
'salt-api': 'salt-api', 'salt_syndic': 'salt-syndic',
'salt-ssh': 'salt-ssh'}, 'salt_cloud': 'salt-cloud',
'Ubuntu': {'salt-master': 'salt-master', 'salt_api': 'salt-api',
'salt-minion': 'salt-minion', 'salt_ssh': 'salt-ssh'},
'salt-syndic': 'salt-syndic', 'Ubuntu': {'salt_master': 'salt-master',
'salt-cloud': 'salt-cloud', 'salt_minion': 'salt-minion',
'salt-api': 'salt-api', 'salt_syndic': 'salt-syndic',
'salt-ssh': 'salt-ssh'}, 'salt_cloud': 'salt-cloud',
'CentOS': {'salt-master': 'salt-master', 'salt_api': 'salt-api',
'salt-minion': 'salt-minion', 'salt_ssh': 'salt-ssh'},
'salt-syndic': 'salt-syndic', 'CentOS': {'salt_master': 'salt-master',
'salt-cloud': 'salt-cloud', 'salt_minion': 'salt-minion',
'salt-api': 'salt-api', 'salt_syndic': 'salt-syndic',
'salt-ssh': 'salt-ssh'}, 'salt_cloud': 'salt-cloud',
'Amazon': {'salt-master': 'salt-master', 'salt_api': 'salt-api',
'salt-minion': 'salt-minion', 'salt_ssh': 'salt-ssh'},
'salt-syndic': 'salt-syndic', 'Amazon': {'salt_master': 'salt-master',
'salt-cloud': 'salt-cloud', 'salt_minion': 'salt-minion',
'salt-api': 'salt-api', 'salt_syndic': 'salt-syndic',
'salt-ssh': 'salt-ssh'}, 'salt_cloud': 'salt-cloud',
'Fedora': {'salt-master': 'salt-master', 'salt_api': 'salt-api',
'salt-minion': 'salt-minion', 'salt_ssh': 'salt-ssh'},
'salt-syndic': 'salt-syndic', 'Fedora': {'salt_master': 'salt-master',
'salt-cloud': 'salt-cloud', 'salt_minion': 'salt-minion',
'salt-api': 'salt-api', 'salt_syndic': 'salt-syndic',
'salt-ssh': 'salt-ssh'}, 'salt_cloud': 'salt-cloud',
'RedHat': {'salt-master': 'salt-master', 'salt_api': 'salt-api',
'salt-minion': 'salt-minion', 'salt_ssh': 'salt-ssh'},
'salt-syndic': 'salt-syndic', 'RedHat': {'salt_master': 'salt-master',
'salt-cloud': 'salt-cloud', 'salt_minion': 'salt-minion',
'salt-api': 'salt-api', 'salt_syndic': 'salt-syndic',
'salt-ssh': 'salt-ssh'}, 'salt_cloud': 'salt-cloud',
'Gentoo': {'salt-master': 'app-admin/salt', 'salt_api': 'salt-api',
'salt-minion': 'app-admin/salt', 'salt_ssh': 'salt-ssh'},
'salt-syndic': 'app-admin/salt', 'Gentoo': {'salt_master': 'app-admin/salt',
'salt-api': 'app-admin/salt', 'salt_minion': 'app-admin/salt',
'salt-cloud': 'app-admin/salt'}, 'salt_syndic': 'app-admin/salt',
'Arch': {'salt-master': 'salt-zmq', 'salt_api': 'app-admin/salt',
'salt-minion': 'salt-zmq', 'salt_cloud': 'app-admin/salt'},
'salt-syndic': 'salt-zmq', 'Arch': {'salt_master': 'salt-zmq',
'salt-cloud': 'salt-zmq', 'salt_minion': 'salt-zmq',
'salt-api': 'salt-zmq', 'salt_syndic': 'salt-zmq',
'salt-ssh': 'salt-zmq'}, 'salt_cloud': 'salt-zmq',
'Suse': {'salt-master': 'salt-master', 'salt_api': 'salt-zmq',
'salt-minion': 'salt-minion', 'salt_ssh': 'salt-zmq'},
'salt-syndic': 'salt-syndic', 'Suse': {'salt_master': 'salt-master',
'salt-api': 'salt-api', 'salt_minion': 'salt-minion',
'salt-cloud': 'salt-cloud', 'salt_syndic': 'salt-syndic',
'salt-ssh': 'salt-ssh'}, 'salt_api': 'salt-api',
'FreeBSD': {'salt-master': 'py27-salt', 'salt_cloud': 'salt-cloud',
'salt-minion': 'py27-salt', 'salt_ssh': 'salt-ssh'},
'salt-syndic': 'py27-salt', 'FreeBSD': {'salt_master': 'py27-salt',
'salt-cloud': 'py27-salt', 'salt_minion': 'py27-salt',
'salt-api': 'py27-salt', 'salt_syndic': 'py27-salt',
'config-path': '/usr/local/etc/salt', 'salt_cloud': 'py27-salt',
'minion-service': 'salt_minion', 'salt_api': 'py27-salt',
'master-service': 'salt_master', 'config_path': '/usr/local/etc/salt',
'api-service': 'salt_api', 'minion_service': 'salt_minion',
'syndic-service': 'salt_syndic'}, 'master_service': 'salt_master',
'api_service': 'salt_api',
'syndic_service': 'salt_syndic'},
}, merge=salt['pillar.get']('salt:lookup')) %} }, merge=salt['pillar.get']('salt:lookup')) %}
{% do default_settings.salt.update(distro_map) %}
{% set salt_settings = salt['pillar.get']('salt', default=default_settings.salt,
merge=True) %}

View File

@ -1,16 +1,16 @@
{% from "salt/map.jinja" import salt with context %} {% from "salt/map.jinja" import salt_settings with context %}
salt-master: salt-master:
pkg.installed: pkg.installed:
- name: {{ salt['salt-master'] }} - name: {{ salt_settings.salt_master }}
file.recurse: file.recurse:
- name: {{ salt.get('config-path', '/etc/salt') }}/master.d - name: {{ salt_settings.config_path }}/master.d
- template: jinja - template: jinja
- source: salt://salt/files/master.d - source: salt://salt/files/master.d
- clean: True - clean: True
service.running: service.running:
- enable: True - enable: True
- name: {{ salt.get('master-service', 'salt-master') }} - name: {{ salt_settings.master_service }}
- watch: - watch:
- pkg: salt-master - pkg: salt-master
- file: salt-master - file: salt-master

View File

@ -1,10 +1,10 @@
{% from "salt/map.jinja" import salt with context %} {% from "salt/map.jinja" import salt_settings with context %}
salt-minion: salt-minion:
pkg.installed: pkg.installed:
- name: {{ salt['salt-minion'] }} - name: {{ salt_settings.salt_minion }}
file.recurse: file.recurse:
- name: {{ salt.get('config-path', '/etc/salt') }}/minion.d - name: {{ salt_settings.config_path }}/minion.d
- template: jinja - template: jinja
- source: salt://salt/files/minion.d - source: salt://salt/files/minion.d
- clean: True - clean: True
@ -12,7 +12,7 @@ salt-minion:
standalone: False standalone: False
service.running: service.running:
- enable: True - enable: True
- name: {{ salt.get('minion-service', 'salt-minion') }} - name: {{ salt_settings.minion_service }}
- watch: - watch:
- pkg: salt-minion - pkg: salt-minion
- file: salt-minion - file: salt-minion

View File

@ -1,12 +1,12 @@
{% from "salt/map.jinja" import salt with context %} {% from "salt/map.jinja" import salt_settings with context %}
ensure salt-ssh is installed: ensure salt-ssh is installed:
pkg.installed: pkg.installed:
- name: {{ salt['salt-ssh'] }} - name: {{ salt_settings.salt_ssh }}
ensure roster config: ensure roster config:
file.managed: file.managed:
- name: {{ salt.get('config_path', '/etc/salt') }}/roster - name: {{ salt_settings.config_path }}/roster
- source: salt://salt/files/roster.jinja - source: salt://salt/files/roster.jinja
- template: jinja - template: jinja
- require: - require:

View File

@ -1,10 +1,10 @@
{% from "salt/map.jinja" import salt with context %} {% from "salt/map.jinja" import salt_settings with context %}
salt-minion: salt-minion:
pkg.installed: pkg.installed:
- name: {{ salt['salt-minion'] }} - name: {{ salt_settings.salt_minion }}
file.recurse: file.recurse:
- name: {{ salt.get('config-path', '/etc/salt') }}/minion.d - name: {{ salt_settings.config_path }}/minion.d
- template: jinja - template: jinja
- source: salt://salt/files/minion.d - source: salt://salt/files/minion.d
- clean: True - clean: True
@ -12,7 +12,7 @@ salt-minion:
standalone: True standalone: True
service.dead: service.dead:
- enable: False - enable: False
- name: {{ salt.get('minion-service', 'salt-minion') }} - name: {{ salt_settings.minion_service }}
- require: - require:
- pkg: salt-minion - pkg: salt-minion
- file: salt-minion - file: salt-minion

View File

@ -1,15 +1,15 @@
{% from "salt/map.jinja" import salt with context %} {% from "salt/map.jinja" import salt_settings with context %}
include: include:
- salt.master - salt.master
salt-syndic: salt-syndic:
pkg.installed: pkg.installed:
- name: {{ salt['salt-syndic'] }} - name: {{ salt_settings.salt_syndic }}
service: service:
- running - running
- require: - require:
- service: {{ salt.get('syndic-service', 'salt-master') }} - service: {{ salt_settings.syndic_service }}
- watch: - watch:
- pkg: salt-master - pkg: salt-master
- file: {{ salt.get('config-path', '/etc/salt') }}/master - file: {{ salt_settings.config_path }}/master