Browse Source

Merge pull request #106 from iggy/cleanup_variable_overwriting

Don't overwrite salt variable
master
Forrest 9 years ago
parent
commit
611e78eb4d
9 changed files with 111 additions and 98 deletions
  1. +4
    -4
      salt/api.sls
  2. +5
    -11
      salt/cloud.sls
  3. +12
    -0
      salt/defaults.yaml
  4. +71
    -64
      salt/map.jinja
  5. +4
    -4
      salt/master.sls
  6. +4
    -4
      salt/minion.sls
  7. +3
    -3
      salt/ssh.sls
  8. +4
    -4
      salt/standalone.sls
  9. +4
    -4
      salt/syndic.sls

+ 4
- 4
salt/api.sls View File

{% 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

+ 5
- 11
salt/cloud.sls View File

{% from "salt/map.jinja" import salt with context %}
{% do salt.update(pillar.get('salt', {})) -%}
{% set cloud = salt.get('cloud', {}) -%}
{% from "salt/map.jinja" import salt_settings with context %}


python-pip: python-pip:
pkg.installed pkg.installed


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
- 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 }}
- 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:
{% 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
- 0
salt/defaults.yaml View File

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

+ 71
- 64
salt/map.jinja View File

{% set salt = salt['grains.filter_by']({
'Debian': {'salt-master': 'salt-master',
'salt-minion': 'salt-minion',
'salt-syndic': 'salt-syndic',
'salt-cloud': 'salt-cloud',
'salt-api': 'salt-api',
'salt-ssh': 'salt-ssh'},
'Ubuntu': {'salt-master': 'salt-master',
'salt-minion': 'salt-minion',
'salt-syndic': 'salt-syndic',
'salt-cloud': 'salt-cloud',
'salt-api': 'salt-api',
'salt-ssh': 'salt-ssh'},
'CentOS': {'salt-master': 'salt-master',
'salt-minion': 'salt-minion',
'salt-syndic': 'salt-syndic',
'salt-cloud': 'salt-cloud',
'salt-api': 'salt-api',
'salt-ssh': 'salt-ssh'},
'Amazon': {'salt-master': 'salt-master',
'salt-minion': 'salt-minion',
'salt-syndic': 'salt-syndic',
'salt-cloud': 'salt-cloud',
'salt-api': 'salt-api',
'salt-ssh': 'salt-ssh'},
'Fedora': {'salt-master': 'salt-master',
'salt-minion': 'salt-minion',
'salt-syndic': 'salt-syndic',
'salt-cloud': 'salt-cloud',
'salt-api': 'salt-api',
'salt-ssh': 'salt-ssh'},
'RedHat': {'salt-master': 'salt-master',
'salt-minion': 'salt-minion',
'salt-syndic': 'salt-syndic',
'salt-cloud': 'salt-cloud',
'salt-api': 'salt-api',
'salt-ssh': 'salt-ssh'},
'Gentoo': {'salt-master': 'app-admin/salt',
'salt-minion': 'app-admin/salt',
'salt-syndic': 'app-admin/salt',
'salt-api': 'app-admin/salt',
'salt-cloud': 'app-admin/salt'},
'Arch': {'salt-master': 'salt-zmq',
'salt-minion': 'salt-zmq',
'salt-syndic': 'salt-zmq',
'salt-cloud': 'salt-zmq',
'salt-api': 'salt-zmq',
'salt-ssh': 'salt-zmq'},
'Suse': {'salt-master': 'salt-master',
'salt-minion': 'salt-minion',
'salt-syndic': 'salt-syndic',
'salt-api': 'salt-api',
'salt-cloud': 'salt-cloud',
'salt-ssh': 'salt-ssh'},
'FreeBSD': {'salt-master': 'py27-salt',
'salt-minion': 'py27-salt',
'salt-syndic': 'py27-salt',
'salt-cloud': 'py27-salt',
'salt-api': 'py27-salt',
'config-path': '/usr/local/etc/salt',
'minion-service': 'salt_minion',
'master-service': 'salt_master',
'api-service': 'salt_api',
'syndic-service': 'salt_syndic'},
{% import_yaml "salt/defaults.yaml" as default_settings %}

{% set distro_map = salt['grains.filter_by']({
'Debian': {'salt_master': 'salt-master',
'salt_minion': 'salt-minion',
'salt_syndic': 'salt-syndic',
'salt_cloud': 'salt-cloud',
'salt_api': 'salt-api',
'salt_ssh': 'salt-ssh'},
'Ubuntu': {'salt_master': 'salt-master',
'salt_minion': 'salt-minion',
'salt_syndic': 'salt-syndic',
'salt_cloud': 'salt-cloud',
'salt_api': 'salt-api',
'salt_ssh': 'salt-ssh'},
'CentOS': {'salt_master': 'salt-master',
'salt_minion': 'salt-minion',
'salt_syndic': 'salt-syndic',
'salt_cloud': 'salt-cloud',
'salt_api': 'salt-api',
'salt_ssh': 'salt-ssh'},
'Amazon': {'salt_master': 'salt-master',
'salt_minion': 'salt-minion',
'salt_syndic': 'salt-syndic',
'salt_cloud': 'salt-cloud',
'salt_api': 'salt-api',
'salt_ssh': 'salt-ssh'},
'Fedora': {'salt_master': 'salt-master',
'salt_minion': 'salt-minion',
'salt_syndic': 'salt-syndic',
'salt_cloud': 'salt-cloud',
'salt_api': 'salt-api',
'salt_ssh': 'salt-ssh'},
'RedHat': {'salt_master': 'salt-master',
'salt_minion': 'salt-minion',
'salt_syndic': 'salt-syndic',
'salt_cloud': 'salt-cloud',
'salt_api': 'salt-api',
'salt_ssh': 'salt-ssh'},
'Gentoo': {'salt_master': 'app-admin/salt',
'salt_minion': 'app-admin/salt',
'salt_syndic': 'app-admin/salt',
'salt_api': 'app-admin/salt',
'salt_cloud': 'app-admin/salt'},
'Arch': {'salt_master': 'salt-zmq',
'salt_minion': 'salt-zmq',
'salt_syndic': 'salt-zmq',
'salt_cloud': 'salt-zmq',
'salt_api': 'salt-zmq',
'salt_ssh': 'salt-zmq'},
'Suse': {'salt_master': 'salt-master',
'salt_minion': 'salt-minion',
'salt_syndic': 'salt-syndic',
'salt_api': 'salt-api',
'salt_cloud': 'salt-cloud',
'salt_ssh': 'salt-ssh'},
'FreeBSD': {'salt_master': 'py27-salt',
'salt_minion': 'py27-salt',
'salt_syndic': 'py27-salt',
'salt_cloud': 'py27-salt',
'salt_api': 'py27-salt',
'config_path': '/usr/local/etc/salt',
'minion_service': 'salt_minion',
'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) %}

+ 4
- 4
salt/master.sls View File

{% 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

+ 4
- 4
salt/minion.sls View File

{% 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
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

+ 3
- 3
salt/ssh.sls View File

{% 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:

+ 4
- 4
salt/standalone.sls View File

{% 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
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

+ 4
- 4
salt/syndic.sls View File

{% 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

Loading…
Cancel
Save