通过salt支柱将ssh密钥从master转发到minion

Modified on: Sat, 20 Jul 2019 00:00:04 +0800

我有两个ssh密钥,我正试图部署到我的一个仆从。但我似乎无法部署它。它出错了。这是支柱中的init.sls

/xxx/yyy/zzz/id_rsa: file.managed: - source: salt://private/id_rsa /xxx/yyy/zz/id_rsa.pub: file.managed: - source: salt://private/id_rsa.pub

这是我的init.sls状态:

ssh: file.managed: - name: {{ pillar['private'] }}

我必须做错事(显然),但我不确定是什么。有什么建议吗?

最佳答案

Salt Pillar系统没有init.sls文件。状态和支柱都有一个top.sls文件。子目录的状态可能有init.sls文件。

第1步:在/srv/pillar/users.sls中定义您的用户

users: - name: fred fullname: Fred Flintstone email: fflintstone@slaterockandgravel.com uid: 4001 gid: 4001 shell: /bin/bash groups: - bowling shadow: $6$Sasdf/Ss$asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfsadfasdfsadfsadfsdf authkey: ssh-dss AAAAasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafa = fflinstone@slaterockandgravel.com sshpub: ssh-dss AAAAasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafa = fflinstone@slaterockandgravel.com - name: barney fullname: Barney Rubble email: brubbel@slaterockandgravel.com uid: 4002 gid: 4002 shell: /bin/bash groups: - bowling shadow: $6$Suiop/Ss$uiopuiopuiopuiopuiopuiopuiopuiopuiopuiopuiopsadfuiopsadfsadfsdf authkey: ssh-dss AAAAuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafa = fflinstone@slaterockandgravel.com sshpub: ssh-dss AAAAuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafa = fflinstone@slaterockandgravel.com

第2步:将新支柱添加到/srv/pillar/top.sls

base: 'testminion': - users

第3步:使用jinja将支柱映射到/srv/salt/user/init.sls中的状态

users:

  - name: fred
    fullname: Fred Flintstone
    email: fflintstone@slaterockandgravel.com
    uid: 4001
    gid: 4001
    shell: /bin/bash
    groups:
      - bowling
    shadow: $6$Sasdf/Ss$asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfsadfasdfsadfsadfsdf
    authkey: ssh-dss AAAAasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafa = fflinstone@slaterockandgravel.com
    sshpub: ssh-dss AAAAasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafaasdfasdfasdfasdfasdfsadfsadfsadfsadfasdfasdfsdafsdafa = fflinstone@slaterockandgravel.com

  - name: barney
    fullname: Barney Rubble
    email: brubbel@slaterockandgravel.com
    uid: 4002
    gid: 4002
    shell: /bin/bash
    groups:
      - bowling
    shadow: $6$Suiop/Ss$uiopuiopuiopuiopuiopuiopuiopuiopuiopuiopuiopsadfuiopsadfsadfsdf
    authkey: ssh-dss AAAAuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafa = fflinstone@slaterockandgravel.com
    sshpub: ssh-dss AAAAuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafauiopuiopuiopuiopuiopsadfsadfsadfsadfuiopuiopsdafsdafa = fflinstone@slaterockandgravel.com

不要忘记将仆从与新柱子同步!

base:
  'testminion':
    - users

相关问答

添加新评论