From a6667cdb8141fbe465236b8a323dd2bcebbecfd0 Mon Sep 17 00:00:00 2001 From: Kenneth Wilke Date: Wed, 14 Aug 2013 14:53:29 -0500 Subject: [PATCH 1/3] Isolated package mapping and some fixes Moved package_table to it's own file, imported by sls files Moved minion package under watch Fixed some template mistakes I made --- salt/files/minion | 6 +++--- salt/master.sls | 8 +++----- salt/minion.sls | 11 ++++------- salt/package-map.jinja | 12 ++++++++++++ 4 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 salt/package-map.jinja 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..7a98204 --- /dev/null +++ b/salt/package-map.jinja @@ -0,0 +1,12 @@ +{% set package_table = { + 'Debian': {'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 %} From fc9db5336a6ccc62526401b77922a272703f8d02 Mon Sep 17 00:00:00 2001 From: Kenneth Wilke Date: Wed, 14 Aug 2013 16:16:50 -0500 Subject: [PATCH 2/3] added moar distro package mapping --- salt/package-map.jinja | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/salt/package-map.jinja b/salt/package-map.jinja index 7a98204..c460e1b 100644 --- a/salt/package-map.jinja +++ b/salt/package-map.jinja @@ -1,6 +1,12 @@ {% 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'} } %} From 48e2e326b2c68ed466d291e8147c252615be53fa Mon Sep 17 00:00:00 2001 From: Kenneth Wilke Date: Wed, 14 Aug 2013 16:21:15 -0500 Subject: [PATCH 3/3] fixed missing curly brackets --- salt/package-map.jinja | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/package-map.jinja b/salt/package-map.jinja index c460e1b..f8e39a6 100644 --- a/salt/package-map.jinja +++ b/salt/package-map.jinja @@ -2,11 +2,11 @@ 'Debian': {'salt-master': 'salt-master', 'salt-minion': 'salt-minion'}, 'Ubuntu': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', + 'salt-minion': 'salt-minion'}, 'CentOS': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', + 'salt-minion': 'salt-minion'}, 'Fedora': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', + 'salt-minion': 'salt-minion'}, 'RedHat': {'salt-master': 'salt-master', 'salt-minion': 'salt-minion'} } %}