diff options
Diffstat (limited to 'roles/sshd/tasks/main.yml')
-rw-r--r-- | roles/sshd/tasks/main.yml | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/roles/sshd/tasks/main.yml b/roles/sshd/tasks/main.yml index f1af386..6a622d2 100644 --- a/roles/sshd/tasks/main.yml +++ b/roles/sshd/tasks/main.yml @@ -1,22 +1,38 @@ +--- + +- name: install openssh + ansible.builtin.package: + name: openssh + state: present + when: ansible_distribution in ["Archlinux"] + - name: generate sshd configuration - template: + ansible.builtin.template: src: sshd_config.j2 - dest: /etc/ssh/sshd_config + dest: "{{ sshd_configuration_file }}" owner: 0 group: 0 - mode: 0644 + mode: "0644" + register: sshd_result_generate_configuration -- name: include key synchronization tasks - include_tasks: synchronize_keys.yml +- name: lint sshd configuration + ansible.builtin.command: "sshd -tf {{ sshd_configuration_file }}" + register: sshd_result_lint + changed_when: false -- name: enable and restart sshd - service: +- name: restart sshd # noqa: no-handler + ansible.builtin.service: name: sshd state: restarted + when: sshd_result_generate_configuration.changed + +- name: enable sshd + ansible.builtin.service: + name: sshd enabled: true - name: check ssh connection - wait_for: - port: "{{ ansible_port }}" + ansible.builtin.wait_for: + port: "{{ sshd_listen_port }}" delay: 1 state: started |