diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2023-01-14 19:02:36 +0100 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2023-04-02 11:45:09 +0200 |
commit | 5d019d2ad90c39cfae2d7edf0208c98060ddbd8e (patch) | |
tree | 9ba7c79b2341b0dc39ce88c221abdeacfc74e2fd /roles | |
parent | 5582074f59640eaad0b879c7c3b45bc3b0beefc8 (diff) | |
download | rules-5d019d2ad90c39cfae2d7edf0208c98060ddbd8e.tar.gz |
feat(roles/sshd): add argument specs
Diffstat (limited to 'roles')
-rw-r--r-- | roles/sshd/meta/main.yml | 21 | ||||
-rw-r--r-- | roles/sshd/tasks/main.yml | 15 |
2 files changed, 34 insertions, 2 deletions
diff --git a/roles/sshd/meta/main.yml b/roles/sshd/meta/main.yml new file mode 100644 index 0000000..e0d60ee --- /dev/null +++ b/roles/sshd/meta/main.yml @@ -0,0 +1,21 @@ +--- + +argument_specs: + main: + short_description: sshd main entrypoint. + options: + + sshd_configuration_file: + type: path + required: true + description: Sshd configuration file + + sshd_listen_port: + type: int + required: true + description: Sshd listen port + + sshd_enable_x11_forwarding: + type: bool + required: true + description: Enable X11 forwarding diff --git a/roles/sshd/tasks/main.yml b/roles/sshd/tasks/main.yml index b895958..6a622d2 100644 --- a/roles/sshd/tasks/main.yml +++ b/roles/sshd/tasks/main.yml @@ -9,15 +9,26 @@ - name: generate sshd configuration ansible.builtin.template: src: sshd_config.j2 - dest: /etc/ssh/sshd_config + dest: "{{ sshd_configuration_file }}" owner: 0 group: 0 mode: "0644" + register: sshd_result_generate_configuration -- name: enable and restart sshd +- name: lint sshd configuration + ansible.builtin.command: "sshd -tf {{ sshd_configuration_file }}" + register: sshd_result_lint + changed_when: false + +- 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 |