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의 상태에 매핑
{% for user in pillar['users'] %}
user_{{user.name}}:
group.present:
- name: {{user.name}}
- gid: {{user.gid}}
user.present:
- name: {{user.name}}
- fullname: {{user.fullname}}
- password: {{user.shadow}}
- shell: {{user.shell}}
- uid: {{user.uid}}
- gid: {{user.gid}}
{% if user.groups %}
- optional_groups:
{% for group in user.groups %}
- {{group}}
{% endfor %}
{% endif %}
- require:
- group: user_{{user.name}}
file.directory:
- name: /home/{{user.name}}
- user: {{user.name}}
- group: {{user.name}}
- mode: 0751
- makedirs: True
user_{{user.name}}_forward:
file.append:
- name: /home/{{user.name}}/.forward
- text: {{user.email}}
user_{{user.name}}_sshdir:
file.directory:
- name: /home/{{user.name}}/.ssh
- user: {{user.name}}
- group: {{user.name}}
- mode: 0700
{% if 'authkey' in user %}
user_{{user.name}}_authkeys:
ssh_auth.present:
- user: {{user.name}}
- name: {{user.authkey}}
{% endif %}
{% if 'sshpriv' in user %}
user_{{user.name}}_sshpriv:
file.managed:
- name: /home/{{user.name}}/.ssh/id_rsa
- user: {{user.name}}
- group: {{user.name}}
- mode: 0600
- contents_pillar: {{user.sshpriv}}
{% endif %}
{% if 'sshpub' in user %}
user_{{user.name}}_sshpub:
file.managed:
- name: /home/{{user.name}}/.ssh/id_rsa.pub
- user: {{user.name}}
- group: {{user.name}}
- mode: 0600
- contents_pillar: {{user.sshpub}}
{% endif %}
{% endfor %} # user in users
# vim: ft=yaml tabstop=2 sts=2 sw=2 et ai si
미니언을 새로운 기둥과 동기화하는 것을 잊지 마십시오!
salt targetminions saltutil.refresh_pillar