Browse Source

Fix invalid require_in sshd_config for key states

Change the require_ins used by the key management states in the
config.sls to be conditional based on whether the sshd_config
is managed by the formula

Fixes #130
tags/v0.41.0
tmeneau 6 years ago
parent
commit
63ad14efb1
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      openssh/config.sls

+ 11
- 1
openssh/config.sls View File

{% from "openssh/map.jinja" import openssh with context %} {% from "openssh/map.jinja" import openssh with context %}


{%- set manage_sshd_config = salt['pillar.get']('sshd_config', False) %}

include: include:
- openssh - openssh


{% if salt['pillar.get']('sshd_config', False) %}
{% if manage_sshd_config %}
sshd_config: sshd_config:
file.managed: file.managed:
- name: {{ openssh.sshd_config }} - name: {{ openssh.sshd_config }}
- contents_pillar: 'openssh:{{ keyType }}:private_key' - contents_pillar: 'openssh:{{ keyType }}:private_key'
- user: root - user: root
- mode: 600 - mode: 600
{%- if manage_sshd_config %}
- require_in: - require_in:
- file: sshd_config - file: sshd_config
{%- endif %}
- watch_in: - watch_in:
- service: {{ openssh.service }} - service: {{ openssh.service }}


- contents_pillar: 'openssh:{{ keyType }}:public_key' - contents_pillar: 'openssh:{{ keyType }}:public_key'
- user: root - user: root
- mode: 600 - mode: 600
{%- if manage_sshd_config %}
- require_in: - require_in:
- file: sshd_config - file: sshd_config
{%- endif %}
- watch_in: - watch_in:
- service: {{ openssh.service }} - service: {{ openssh.service }}
{%- elif salt['pillar.get']('openssh:generate_' ~ keyType ~ '_keys', False) %} {%- elif salt['pillar.get']('openssh:generate_' ~ keyType ~ '_keys', False) %}
- name: "rm {{ keyFile }}*; ssh-keygen -t {{ keyType }} {{ keySizePart }} -N '' -f {{ keyFile }}" - name: "rm {{ keyFile }}*; ssh-keygen -t {{ keyType }} {{ keySizePart }} -N '' -f {{ keyFile }}"
- unless: "test -s {{ keyFile }}" - unless: "test -s {{ keyFile }}"
- runas: root - runas: root
{%- if manage_sshd_config %}
- require_in: - require_in:
- file: sshd_config - file: sshd_config
{%- endif %}
- watch_in: - watch_in:
- service: {{ openssh.service }} - service: {{ openssh.service }}


- mode: 0600 - mode: 0600
- require: - require:
- cmd: ssh_generate_host_{{ keyType }}_key - cmd: ssh_generate_host_{{ keyType }}_key
{%- if manage_sshd_config %}
- require_in: - require_in:
- file: sshd_config - file: sshd_config
{%- endif %}


{%- elif salt['pillar.get']('openssh:absent_' ~ keyType ~ '_keys', False) %} {%- elif salt['pillar.get']('openssh:absent_' ~ keyType ~ '_keys', False) %}
ssh_host_{{ keyType }}_key: ssh_host_{{ keyType }}_key:

Loading…
Cancel
Save