From 896578a75a2ed1b4697f60c76636c4c11304a812 Mon Sep 17 00:00:00 2001 From: Niels Abspoel Date: Wed, 31 Dec 2014 11:52:31 +0100 Subject: [PATCH 1/2] Removed package_map lookup Added map.jinja solution more in line with other formulas, This also improves issue #30 and pull request #30 --- salt/cloud.sls | 2 +- salt/map.jinja | 53 +++++++++++++++++++++++++++++++++++++++++++++ salt/master.sls | 2 +- salt/minion.sls | 2 +- salt/ssh.sls | 2 +- salt/standalone.sls | 2 +- salt/syndic.sls | 2 +- 7 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 salt/map.jinja diff --git a/salt/cloud.sls b/salt/cloud.sls index 41c753b..be62f5d 100644 --- a/salt/cloud.sls +++ b/salt/cloud.sls @@ -1,4 +1,4 @@ -{% from "salt/package-map.jinja" import pkgs with context %} +{% from "salt/map.jinja" import pkgs with context %} {% set salt = pillar.get('salt', {}) -%} {% set cloud = salt.get('cloud', {}) -%} diff --git a/salt/map.jinja b/salt/map.jinja new file mode 100644 index 0000000..e342330 --- /dev/null +++ b/salt/map.jinja @@ -0,0 +1,53 @@ +{% set pkgs = salt['grains.filter_by']({ + 'Debian': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion', + 'salt-syndic': 'salt-syndic', + 'salt-cloud': 'salt-cloud', + 'salt-ssh': 'salt-ssh'}, + 'Ubuntu': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion', + 'salt-syndic': 'salt-syndic', + 'salt-cloud': 'salt-cloud', + 'salt-ssh': 'salt-ssh'}, + 'CentOS': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion', + 'salt-syndic': 'salt-syndic', + 'salt-cloud': 'salt-cloud', + 'salt-ssh': 'salt-ssh'}, + 'Amazon': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion', + 'salt-syndic': 'salt-syndic', + 'salt-cloud': 'salt-cloud', + 'salt-ssh': 'salt-ssh'}, + 'Fedora': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion', + 'salt-syndic': 'salt-syndic', + 'salt-cloud': 'salt-cloud', + 'salt-ssh': 'salt-ssh'}, + 'RedHat': {'salt-master': 'salt-master', + 'salt-minion': 'salt-minion', + 'salt-syndic': 'salt-syndic', + 'salt-cloud': 'salt-cloud', + 'salt-ssh': 'salt-ssh'}, + 'Gentoo': {'salt-master': 'app-admin/salt', + 'salt-minion': 'app-admin/salt', + 'salt-syndic': 'app-admin/salt', + 'salt-cloud': 'app-admin/salt'}, + 'Arch': {'salt-master': 'salt', + 'salt-minion': 'salt', + 'salt-syndic': 'salt', + 'salt-cloud': 'salt'}, + 'openSUSE':{'salt-master': 'salt-master', + 'salt-minion': 'salt-minion', + 'salt-syndic': 'salt-syndic', + 'salt-cloud': 'salt-cloud'}, + 'FreeBSD': {'salt-master': 'py27-salt', + 'salt-minion': 'py27-salt', + 'salt-syndic': 'py27-salt', + 'salt-cloud': 'py27-salt', + 'config-path': '/usr/local/etc/salt', + 'minion-service': 'salt_minion', + 'master-service': 'salt_master', + 'syndic-service': 'salt_syndic'}, +}, +merge=salt['pillar.get']('salt:lookup'), base='default') %} diff --git a/salt/master.sls b/salt/master.sls index baa2e2b..2cb3bd0 100644 --- a/salt/master.sls +++ b/salt/master.sls @@ -1,4 +1,4 @@ -{% from "salt/package-map.jinja" import pkgs with context %} +{% from "salt/map.jinja" import pkgs with context %} salt-master: pkg.installed: diff --git a/salt/minion.sls b/salt/minion.sls index a80e210..a33172f 100644 --- a/salt/minion.sls +++ b/salt/minion.sls @@ -1,4 +1,4 @@ -{% from "salt/package-map.jinja" import pkgs with context %} +{% from "salt/map.jinja" import pkgs with context %} salt-minion: pkg.installed: diff --git a/salt/ssh.sls b/salt/ssh.sls index 2f6aece..e32f5eb 100644 --- a/salt/ssh.sls +++ b/salt/ssh.sls @@ -1,4 +1,4 @@ -{% from "salt/package-map.jinja" import pkgs with context %} +{% from "salt/map.jinja" import pkgs with context %} ensure salt-ssh is installed: pkg.installed: diff --git a/salt/standalone.sls b/salt/standalone.sls index e33da85..e4a8cd2 100644 --- a/salt/standalone.sls +++ b/salt/standalone.sls @@ -1,4 +1,4 @@ -{% from "salt/package-map.jinja" import pkgs with context %} +{% from "salt/map.jinja" import pkgs with context %} salt-minion: pkg.installed: diff --git a/salt/syndic.sls b/salt/syndic.sls index 0804d98..5af99e4 100644 --- a/salt/syndic.sls +++ b/salt/syndic.sls @@ -1,4 +1,4 @@ -{% from "salt/package-map.jinja" import pkgs with context %} +{% from "salt/map.jinja" import pkgs with context %} include: - salt.master From 4dc0044772fd96118e59a2656dae88ff11b97e3d Mon Sep 17 00:00:00 2001 From: Niels Abspoel Date: Wed, 7 Jan 2015 21:06:02 +0100 Subject: [PATCH 2/2] update use_lookup_map with merges from upstream --- salt/package-map.jinja | 58 ------------------------------------------ 1 file changed, 58 deletions(-) delete mode 100644 salt/package-map.jinja diff --git a/salt/package-map.jinja b/salt/package-map.jinja deleted file mode 100644 index 770de38..0000000 --- a/salt/package-map.jinja +++ /dev/null @@ -1,58 +0,0 @@ -{% set package_table = { - 'Debian': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', - 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud', - 'salt-ssh': 'salt-ssh'}, - 'Ubuntu': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', - 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud', - 'salt-ssh': 'salt-ssh'}, - 'CentOS': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', - 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud', - 'salt-ssh': 'salt-ssh'}, - 'Amazon': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', - 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud', - 'salt-ssh': 'salt-ssh'}, - 'Fedora': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', - 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud', - 'salt-ssh': 'salt-ssh'}, - 'RedHat': {'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', - 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud', - 'salt-ssh': 'salt-ssh'}, - 'Gentoo': {'salt-master': 'app-admin/salt', - 'salt-minion': 'app-admin/salt', - 'salt-syndic': 'app-admin/salt', - 'salt-cloud': 'app-admin/salt'}, - 'Arch': {'salt-master': 'salt', - 'salt-minion': 'salt', - 'salt-syndic': 'salt', - 'salt-cloud': 'salt'}, - 'openSUSE':{'salt-master': 'salt-master', - 'salt-minion': 'salt-minion', - 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud'}, - 'FreeBSD': {'salt-master': 'py27-salt', - 'salt-minion': 'py27-salt', - 'salt-syndic': 'py27-salt', - 'salt-cloud': 'py27-salt', - 'config-path': '/usr/local/etc/salt', - 'minion-service': 'salt_minion', - 'master-service': 'salt_master', - 'syndic-service': 'salt_syndic'} -} %} - -{% if 'package_table' in pillar %} - {% set pkgs = pillar['package_table'] %} -{% elif grains['os'] in package_table %} - {% set pkgs = package_table[grains['os']] %} -{% endif %}