From 33344743b069710e0147b074f236bbf8957b1840 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 27 Dec 2015 18:17:01 +0100 Subject: [PATCH] Add ability to control SSH server status (default: on) --- openssh/defaults.yaml | 1 + openssh/init.sls | 8 +++++++- pillar.example | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/openssh/defaults.yaml b/openssh/defaults.yaml index c58bf08..8f21dc9 100644 --- a/openssh/defaults.yaml +++ b/openssh/defaults.yaml @@ -1,4 +1,5 @@ openssh: + sshd_enable: True sshd_config: /etc/ssh/sshd_config sshd_config_src: salt://openssh/files/sshd_config ssh_config: /etc/ssh/ssh_config diff --git a/openssh/init.sls b/openssh/init.sls index 3cf9be6..73d1ba8 100644 --- a/openssh/init.sls +++ b/openssh/init.sls @@ -5,10 +5,16 @@ openssh: pkg.installed: - name: {{ openssh.server }} {% endif %} + {% if openssh.sshd_enable is sameas true %} service.running: - - enable: True + - enable: {{ openssh.sshd_enable }} - name: {{ openssh.service }} {% if openssh.server is defined %} - require: - pkg: {{ openssh.server }} {% endif %} + {% else %} + service.dead: + - enable: False + - name: {{ openssh.service }} + {% endif %} diff --git a/pillar.example b/pillar.example index 7db11b1..9a5b035 100644 --- a/pillar.example +++ b/pillar.example @@ -81,6 +81,8 @@ ssh_config: VisualHostKey: 'no' openssh: + # Controls if SSHD should be enabled/started + sshd_enable: true auth: joe-valid-ssh-key-desktop: - user: joe