diff --git a/openssh/init.sls b/openssh/init.sls index 6ea329b..f70539d 100644 --- a/openssh/init.sls +++ b/openssh/init.sls @@ -1,25 +1,24 @@ +{% from "openssh/map.jinja" import openssh with context %} + openssh: - pkg: - - installed - {% if grains['os_family'] == 'Debian' %} - - name: openssh-server - {% endif %} + pkg.installed: + - name: {{ openssh.server }} service.running: - enable: True - - name: ssh + - name: {{ openssh.service }} - require: - - pkg: openssh + - pkg: {{ openssh.server }} - file: sshd_banner - watch: - file: sshd_config sshd_config: file.managed: - - name: /etc/ssh/sshd_config - - source: salt://openssh/files/sshd_config + - name: {{ openssh.sshd_config }} + - source: {{ openssh.sshd_config_src }} sshd_banner: file.managed: - - name: /etc/ssh/banner - - source: salt://openssh/files/banner + - name: {{ openssh.banner }} + - source: {{ openssh.banner_src }} - template: jinja diff --git a/openssh/map.jinja b/openssh/map.jinja new file mode 100644 index 0000000..9376e5e --- /dev/null +++ b/openssh/map.jinja @@ -0,0 +1,18 @@ +{% set openssh = salt['grains.filter_by']({ + 'Debian': { + 'server': 'openssh-server', + 'service': 'ssh', + 'sshd_config': '/etc/ssh/sshd_config', + 'sshd_config_src': 'salt://openssh/files/sshd_config', + 'banner': '/etc/ssh/banner', + 'banner_src': 'salt://openssh/files/banner', + }, + 'RedHat': { + 'server': 'openssh-server', + 'service': 'sshd', + 'sshd_config': '/etc/ssh/sshd_config', + 'sshd_config_src': 'salt://openssh/files/sshd_config', + 'banner': '/etc/ssh/banner', + 'banner_src': 'salt://openssh/files/banner', + }, +}, merge=salt['pillar.get']('openssh:lookup')) %}