diff --git a/salt/files/minion b/salt/files/minion index cb7f214..239946a 100644 --- a/salt/files/minion +++ b/salt/files/minion @@ -294,7 +294,7 @@ id: {{ minion['id'] }} # # The failhard option tells the minions to stop immediately after the first # failure detected in the state execution, defaults to False -{{ get_config(failhard'', 'False') }} +{{ get_config('failhard', 'False') }} # # autoload_dynamic_modules Turns on automatic loading of modules found in the # environments on the master. This is turned on by default, to turn of @@ -389,9 +389,9 @@ file_roots: # The Salt pillar is searched for locally if file_client is set to local. If # this is the case, and pillar data is defined, then the pillar_roots need to # also be configured on the minion: -{% if 'pillar_roots' in master -%} +{% if 'pillar_roots' in minion -%} pillar_roots: - {% for name, roots in master['pillar_roots'].items() -%} + {% for name, roots in minion['pillar_roots'].items() -%} {{ name }}: {% for dir in roots -%} - {{ dir }} diff --git a/salt/master.sls b/salt/master.sls index f4fb679..b910d5a 100644 --- a/salt/master.sls +++ b/salt/master.sls @@ -1,10 +1,8 @@ +{% from "salt/package-map.jinja" import pkgs with context %} + salt-master: pkg.installed: - {% if grains['os_family'] in ['RedHat', 'Debian'] %} - - name: salt-master - {% else %} - - name: salt - {% endif %} + - name: {{ pkgs['salt-master'] }} file.managed: - name: /etc/salt/master - template: jinja diff --git a/salt/minion.sls b/salt/minion.sls index 7917e07..00c3ea0 100644 --- a/salt/minion.sls +++ b/salt/minion.sls @@ -1,17 +1,14 @@ +{% from "salt/package-map.jinja" import pkgs with context %} + salt-minion: pkg.installed: - {% if grains['os_family'] in ['RedHat', 'Debian'] %} - - name: salt-minion - {% else %} - - name: salt - {% endif %} + - name: {{ pkgs['salt-minion'] }} file.managed: - name: /etc/salt/minion - template: jinja - source: salt://salt/files/minion service.running: - enable: True - - require: - - pkg: salt-minion - watch: + - pkg: salt-minion - file: salt-minion diff --git a/salt/package-map.jinja b/salt/package-map.jinja new file mode 100644 index 0000000..f8e39a6 --- /dev/null +++ b/salt/package-map.jinja @@ -0,0 +1,18 @@ +{% set package_table = { + 'Debian': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion'}, + 'Ubuntu': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion'}, + 'CentOS': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion'}, + 'Fedora': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion'}, + 'RedHat': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion'} +} %} + +{% if 'package_table' in pillar %} + {% set pkgs = pillar['package_table'] %} +{% elif grains['os'] in package_table %} + {% set pkgs = package_table[grains['os']] %} +{% endif %}