machine_setup/ansible/roles/sshd/tasks/peruser.yaml

27 lines
668 B
YAML
Raw Normal View History

2022-10-12 03:51:42 +00:00
- include_role:
name: per_user
2022-10-13 00:16:27 +00:00
- name: Create ssh directory
file:
name: "{{ account_homedir.stdout }}/.ssh"
state: directory
mode: 0700
owner: "{{ account_name.stdout }}"
group: "{{ group_name.stdout }}"
2022-10-12 03:51:42 +00:00
2022-10-13 00:16:27 +00:00
- name: Set authorized keys
authorized_key:
user: "{{ account_name.stdout }}"
key: |
{% for user in users[account_name.stdout].authorized_keys %}
{{ lookup('file', './files/keys/' + user + '.pub') }}
{% endfor %}
exclusive: true
notify: "restart sshd"
2022-10-12 03:51:42 +00:00
- import_tasks: tasks/peruser_freebsd.yaml
when: 'os_flavor == "freebsd"'
- import_tasks: tasks/peruser_linux.yaml
when: 'os_flavor == "linux"'