From cde16097ed3be7ca1a421eb37f63f5e6118e50c5 Mon Sep 17 00:00:00 2001 From: Tim O'Guin Date: Tue, 28 Oct 2014 11:45:32 -0500 Subject: [PATCH 1/3] add support for installing salt-ssh and managing the roster file, updated README and pillar.example --- README.rst | 6 ++++++ pillar.example | 6 ++++++ salt/files/roster.jinja | 12 ++++++++++++ salt/package-map.jinja | 3 ++- salt/ssh.sls | 13 +++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 salt/files/roster.jinja create mode 100644 salt/ssh.sls diff --git a/README.rst b/README.rst index a01932f..c61eb0c 100644 --- a/README.rst +++ b/README.rst @@ -35,6 +35,12 @@ Install a syndic. Install salt cloud. +``salt.ssh`` +------------ + +Install salt-ssh with roster file. +Configure pillar data under salt:ssh_roster to feed the template. + ``Configuration`` ================= Every option available in the templates can be set in pillar. Settings under 'salt' will be overridden by more specific settings under ``salt['master']``, ``salt['minion']`` or ``salt['cloud']`` diff --git a/pillar.example b/pillar.example index 48f9956..1baebc6 100644 --- a/pillar.example +++ b/pillar.example @@ -45,6 +45,12 @@ salt: reactor: - 'deploy': - /srv/salt/reactors/deploy.sls + ssh_roster: + prod1: + host: host.example.com + user: ubuntu + sudo: True + priv: /etc/salt/ssh_keys/sshkey.pem salt_cloud_certs: aws: diff --git a/salt/files/roster.jinja b/salt/files/roster.jinja new file mode 100644 index 0000000..32429f9 --- /dev/null +++ b/salt/files/roster.jinja @@ -0,0 +1,12 @@ +# +# This file is managed by Salt! Do not edit by hand! +# +{%- set roster = salt['pillar.get']('salt:ssh_roster') -%} +{%- if roster %} + {%- for host, options in roster.items() %} +{{ host }}: + {%- for k, v in options.items() %} + {{ k }}: {{ v }} + {%- endfor %} + {% endfor %} +{%- endif -%} diff --git a/salt/package-map.jinja b/salt/package-map.jinja index 243d12d..69773d8 100644 --- a/salt/package-map.jinja +++ b/salt/package-map.jinja @@ -6,7 +6,8 @@ 'Ubuntu': {'salt-master': 'salt-master', 'salt-minion': 'salt-minion', 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud'}, + 'salt-cloud': 'salt-cloud', + 'salt-ssh': 'salt-ssh'}, 'CentOS': {'salt-master': 'salt-master', 'salt-minion': 'salt-minion', 'salt-syndic': 'salt-syndic', diff --git a/salt/ssh.sls b/salt/ssh.sls new file mode 100644 index 0000000..2f6aece --- /dev/null +++ b/salt/ssh.sls @@ -0,0 +1,13 @@ +{% from "salt/package-map.jinja" import pkgs with context %} + +ensure salt-ssh is installed: + pkg.installed: + - name: {{ pkgs['salt-ssh'] }} + +ensure roster config: + file.managed: + - name: {{ pkgs.get('config_path', '/etc/salt') }}/roster + - source: salt://salt/files/roster.jinja + - template: jinja + - require: + - pkg: ensure salt-ssh is installed From a3c54f0e8fc2505fe26c52942c81c5b3133161e5 Mon Sep 17 00:00:00 2001 From: Tim O'Guin Date: Tue, 28 Oct 2014 11:46:38 -0500 Subject: [PATCH 2/3] added salt-ssh to package-map.jinja for most OS families --- salt/package-map.jinja | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/salt/package-map.jinja b/salt/package-map.jinja index 69773d8..ef27ad2 100644 --- a/salt/package-map.jinja +++ b/salt/package-map.jinja @@ -2,7 +2,8 @@ 'Debian': {'salt-master': 'salt-master', 'salt-minion': 'salt-minion', 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud'}, + 'salt-cloud': 'salt-cloud', + 'salt-ssh': 'salt-ssh'}, 'Ubuntu': {'salt-master': 'salt-master', 'salt-minion': 'salt-minion', 'salt-syndic': 'salt-syndic', @@ -12,18 +13,22 @@ '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', From cfa1f4eafc4f05ada8b802028657df0081ac287b Mon Sep 17 00:00:00 2001 From: Tim O'Guin Date: Tue, 28 Oct 2014 11:50:23 -0500 Subject: [PATCH 3/3] fix syntax issues in package-map.jinja --- salt/package-map.jinja | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/package-map.jinja b/salt/package-map.jinja index ef27ad2..38f3888 100644 --- a/salt/package-map.jinja +++ b/salt/package-map.jinja @@ -12,22 +12,22 @@ 'CentOS': {'salt-master': 'salt-master', 'salt-minion': 'salt-minion', 'salt-syndic': 'salt-syndic', - 'salt-cloud': 'salt-cloud'}, + '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-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-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-cloud': 'salt-cloud', 'salt-ssh': 'salt-ssh'}, 'Gentoo': {'salt-master': 'app-admin/salt', 'salt-minion': 'app-admin/salt',