diff options
Diffstat (limited to 'roles/sshd/tasks')
-rw-r--r-- | roles/sshd/tasks/main.yml | 13 | ||||
-rw-r--r-- | roles/sshd/tasks/synchronize_keys.yml | 20 |
2 files changed, 8 insertions, 25 deletions
diff --git a/roles/sshd/tasks/main.yml b/roles/sshd/tasks/main.yml index df5d845..b895958 100644 --- a/roles/sshd/tasks/main.yml +++ b/roles/sshd/tasks/main.yml @@ -1,15 +1,18 @@ --- +- name: install openssh + ansible.builtin.package: + name: openssh + state: present + when: ansible_distribution in ["Archlinux"] + - name: generate sshd configuration ansible.builtin.template: src: sshd_config.j2 dest: /etc/ssh/sshd_config owner: 0 group: 0 - mode: 0644 - -- name: include key synchronization tasks - ansible.builtin.include_tasks: synchronize_keys.yml + mode: "0644" - name: enable and restart sshd ansible.builtin.service: @@ -19,6 +22,6 @@ - name: check ssh connection ansible.builtin.wait_for: - port: "{{ ansible_port }}" + port: "{{ sshd_listen_port }}" delay: 1 state: started diff --git a/roles/sshd/tasks/synchronize_keys.yml b/roles/sshd/tasks/synchronize_keys.yml deleted file mode 100644 index 32f6b5a..0000000 --- a/roles/sshd/tasks/synchronize_keys.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: get ssh keys for all users - ansible.builtin.find: - paths: files/keys - file_type: link - recurse: true - delegate_to: localhost - run_once: true - register: result - -- name: synchronize ssh keys - ansible.posix.authorized_key: - user: "{{ item.path | dirname | basename }}" - state: present - key: "{{ lookup('file', item.path) }}" - loop_control: - label: "{{ item.path }} -> user: {{ item.path | dirname | basename }}" - loop: "{{ result.files }}" - failed_when: false |