Просмотр исходного кода

Don't overwrite salt variable

Using a variable named salt is a bad idea when salt already has a variable
named salt.
master
Brian Jackson 9 лет назад
Родитель
Сommit
cb3aa80c62
9 измененных файлов: 111 добавлений и 98 удалений
  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 Просмотреть файл

@@ -1,14 +1,14 @@
{% from "salt/map.jinja" import salt with context %}
{% from "salt/map.jinja" import salt_settings with context %}

include:
- salt.master

salt-api:
pkg.installed:
- name: {{ salt['salt-api'] }}
- name: {{ salt_settings.salt_api }}
service.running:
- name: {{ salt.get('api-service', 'salt-api') }}
- name: {{ salt_settings.api_service }}
- require:
- service: {{ salt.get('api-service', 'salt-master') }}
- service: {{ salt_settings.api_service }}
- watch:
- pkg: salt-master

+ 5
- 11
salt/cloud.sls Просмотреть файл

@@ -1,6 +1,4 @@
{% 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:
pkg.installed
@@ -24,7 +22,7 @@ apache-libcloud:

salt-cloud:
pkg.installed:
- name: {{ salt['salt-cloud'] }}
- name: {{ salt_settings.salt_cloud }}
- require:
- pip: apache-libcloud
- pip: pycrypto
@@ -32,7 +30,7 @@ salt-cloud:
- pip: crypto
{% endif %}

{% for folder in cloud['folders'] %}
{% for folder in salt_settings.cloud.folders %}
{{ folder }}:
file.directory:
- name: /etc/salt/{{ folder }}
@@ -43,7 +41,7 @@ salt-cloud:
- makedirs: True
{% endfor %}

{% for cert in pillar.get('salt_cloud_certs', {}) %}
{% for cert in salt_settings.salt_cloud_certs %}
{% for type in ['pem'] %}
cloud-cert-{{ cert }}-pem:
file.managed:
@@ -59,23 +57,19 @@ cloud-cert-{{ cert }}-pem:
{% endfor %}
{% endfor %}

{% for providers in cloud['providers'] %}
{% for providers in salt_settings.cloud.providers %}
salt-cloud-profiles-{{ providers }}:
file.managed:
- name: /etc/salt/cloud.profiles.d/{{ providers }}.conf
- template: jinja
- source: salt://salt/files/cloud.profiles.d/{{ providers }}.conf
{% endfor %}

{% for providers in cloud['providers'] %}
salt-cloud-providers-{{ providers }}:
file.managed:
- name: /etc/salt/cloud.providers.d/{{ providers }}.conf
- template: jinja
- source: salt://salt/files/cloud.providers.d/{{ providers }}.conf
{% endfor %}

{% for providers in cloud['providers'] %}
salt-cloud-maps-{{ providers }}:
file.managed:
- name: /etc/salt/cloud.maps.d/{{ providers }}.conf

+ 12
- 0
salt/defaults.yaml Просмотреть файл

@@ -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

+ 71
- 64
salt/map.jinja Просмотреть файл

@@ -1,65 +1,72 @@
{% 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')) %}

{% 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 Просмотреть файл

@@ -1,16 +1,16 @@
{% from "salt/map.jinja" import salt with context %}
{% from "salt/map.jinja" import salt_settings with context %}

salt-master:
pkg.installed:
- name: {{ salt['salt-master'] }}
- name: {{ salt_settings.salt_master }}
file.recurse:
- name: {{ salt.get('config-path', '/etc/salt') }}/master.d
- name: {{ salt_settings.config_path }}/master.d
- template: jinja
- source: salt://salt/files/master.d
- clean: True
service.running:
- enable: True
- name: {{ salt.get('master-service', 'salt-master') }}
- name: {{ salt_settings.master_service }}
- watch:
- pkg: salt-master
- file: salt-master

+ 4
- 4
salt/minion.sls Просмотреть файл

@@ -1,10 +1,10 @@
{% from "salt/map.jinja" import salt with context %}
{% from "salt/map.jinja" import salt_settings with context %}

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

+ 3
- 3
salt/ssh.sls Просмотреть файл

@@ -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:
pkg.installed:
- name: {{ salt['salt-ssh'] }}
- name: {{ salt_settings.salt_ssh }}

ensure roster config:
file.managed:
- name: {{ salt.get('config_path', '/etc/salt') }}/roster
- name: {{ salt_settings.config_path }}/roster
- source: salt://salt/files/roster.jinja
- template: jinja
- require:

+ 4
- 4
salt/standalone.sls Просмотреть файл

@@ -1,10 +1,10 @@
{% from "salt/map.jinja" import salt with context %}
{% from "salt/map.jinja" import salt_settings with context %}

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

+ 4
- 4
salt/syndic.sls Просмотреть файл

@@ -1,15 +1,15 @@
{% from "salt/map.jinja" import salt with context %}
{% from "salt/map.jinja" import salt_settings with context %}

include:
- salt.master

salt-syndic:
pkg.installed:
- name: {{ salt['salt-syndic'] }}
- name: {{ salt_settings.salt_syndic }}
service:
- running
- require:
- service: {{ salt.get('syndic-service', 'salt-master') }}
- service: {{ salt_settings.syndic_service }}
- watch:
- pkg: salt-master
- file: {{ salt.get('config-path', '/etc/salt') }}/master
- file: {{ salt_settings.config_path }}/master

Загрузка…
Отмена
Сохранить