浏览代码

Config: Refactor host key provisioning into loop

tags/v0.41.0
Alan Pearce 10 年前
父节点
当前提交
ce46343562
共有 1 个文件被更改,包括 9 次插入27 次删除
  1. +9
    -27
      openssh/config.sls

+ 9
- 27
openssh/config.sls 查看文件

@@ -13,42 +13,24 @@ sshd_config:
- watch_in:
- service: openssh

{% if salt['pillar.get']('openssh:provide_dsa_keys', False) %}
ssh_host_dsa_key:
{% for keyType in ['dsa', 'rsa'] %}
{% if salt['pillar.get']('openssh:provide_' ~ keyType ~ '_keys', False) %}
ssh_host_{{ keyType }}_key:
file.managed:
- name: /etc/ssh/ssh_host_dsa_key
- contents_pillar: 'openssh:dsa:private_key'
- name: /etc/ssh/ssh_host_{{ keyType }}_key
- contents_pillar: 'openssh:{{ keyType }}:private_key'
- user: root
- mode: 600
- require_in:
- service: {{ openssh.service }}

ssh_host_dsa_key.pub:
ssh_host_{{ keyType }}_key.pub:
file.managed:
- name: /etc/ssh/ssh_host_dsa_key.pub
- contents_pillar: 'openssh:dsa:public_key'
- user: root
- mode: 600
- require_in:
- service: {{ openssh.service }}
{% endif %}

{% if salt['pillar.get']('openssh:provide_rsa_keys', False) %}
ssh_host_rsa_key:
file.managed:
- name: /etc/ssh/ssh_host_rsa_key
- contents_pillar: 'openssh:rsa:private_key'
- user: root
- mode: 600
- require_in:
- service: {{ openssh.service }}

ssh_host_rsa_key.pub:
file.managed:
- name: /etc/ssh/ssh_host_rsa_key.pub
- contents_pillar: 'openssh:rsa:public_key'
- name: /etc/ssh/ssh_host_{{ keyType }}_key.pub
- contents_pillar: 'openssh:{{ keyType }}:public_key'
- user: root
- mode: 600
- require_in:
- service: {{ openssh.service }}
{% endif %}
{% endfor %}

正在加载...
取消
保存