浏览代码

Merge pull request #168 from konstest/master

Support "salt://path_to_keyname" ssh_key definition in users:"user name":ssh_keys:"privkey|pubkey" pillar data
tags/v0.45.0
N 6 年前
父节点
当前提交
839058b851
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. +3
    -0
      pillar.example
  2. +5
    -0
      users/init.sls

+ 3
- 0
pillar.example 查看文件

@@ -57,6 +57,9 @@ users:
ssh_keys:
privkey: PRIVATEKEY
pubkey: PUBLICKEY
# or you can provide path to key on Salt fileserver
privkey: salt://path_to_PRIVATEKEY
pubkey: salt://path_to_PUBLICKEY
# you can provide multiple keys, the keyname is taken as filename
# make sure your public keys suffix is .pub
foobar: PRIVATEKEY

+ 5
- 0
users/init.sls 查看文件

@@ -195,7 +195,12 @@ users_{{ name }}_{{ key_name }}_key:
- mode: 600
{% endif %}
- show_diff: False
{%- set key_value = salt['pillar.get']('users:'+name+':ssh_keys:'+_key) %}
{%- if 'salt://' in key_value[:7] %}
- source: {{ key_value }}
{%- else %}
- contents_pillar: users:{{ name }}:ssh_keys:{{ _key }}
{%- endif %}
- require:
- user: users_{{ name }}_user
{% for group in user.get('groups', []) %}

正在加载...
取消
保存