From adfb09b9e19f7a31632eab01171693cb81ec75ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Thu, 8 Feb 2024 13:32:37 +0100 Subject: refactor(roles): new variable naming standard --- roles/sshd/defaults/main.yml | 6 +++--- roles/sshd/meta/main.yml | 6 +++--- roles/sshd/tasks/main.yml | 12 ++++++------ roles/sshd/templates/sshd_config.j2 | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'roles/sshd') diff --git a/roles/sshd/defaults/main.yml b/roles/sshd/defaults/main.yml index 87933b9..85df472 100644 --- a/roles/sshd/defaults/main.yml +++ b/roles/sshd/defaults/main.yml @@ -1,5 +1,5 @@ --- -sshd_configuration_file: /etc/ssh/sshd_config -sshd_listen_port: 22 -sshd_enable_x11_forwarding: false +sshd__configuration_file: /etc/ssh/sshd_config +sshd__listen_port: 22 +sshd__enable_x11_forwarding: false diff --git a/roles/sshd/meta/main.yml b/roles/sshd/meta/main.yml index e0d60ee..7edf5cf 100644 --- a/roles/sshd/meta/main.yml +++ b/roles/sshd/meta/main.yml @@ -5,17 +5,17 @@ argument_specs: short_description: sshd main entrypoint. options: - sshd_configuration_file: + sshd__configuration_file: type: path required: true description: Sshd configuration file - sshd_listen_port: + sshd__listen_port: type: int required: true description: Sshd listen port - sshd_enable_x11_forwarding: + 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 6a622d2..05221fd 100644 --- a/roles/sshd/tasks/main.yml +++ b/roles/sshd/tasks/main.yml @@ -9,22 +9,22 @@ - name: generate sshd configuration ansible.builtin.template: src: sshd_config.j2 - dest: "{{ sshd_configuration_file }}" + dest: "{{ sshd__configuration_file }}" owner: 0 group: 0 mode: "0644" - register: sshd_result_generate_configuration + register: sshd__result_generate_configuration - name: lint sshd configuration - ansible.builtin.command: "sshd -tf {{ sshd_configuration_file }}" - register: sshd_result_lint + 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 + when: sshd__result_generate_configuration.changed - name: enable sshd ansible.builtin.service: @@ -33,6 +33,6 @@ - name: check ssh connection ansible.builtin.wait_for: - port: "{{ sshd_listen_port }}" + port: "{{ sshd__listen_port }}" delay: 1 state: started diff --git a/roles/sshd/templates/sshd_config.j2 b/roles/sshd/templates/sshd_config.j2 index b8affa8..179738a 100644 --- a/roles/sshd/templates/sshd_config.j2 +++ b/roles/sshd/templates/sshd_config.j2 @@ -1,7 +1,7 @@ # managed by Ansible # network -Port {{ sshd_listen_port }} +Port {{ sshd__listen_port }} # security PermitRootLogin yes @@ -13,7 +13,7 @@ AuthorizedKeysFile .ssh/authorized_keys PasswordAuthentication no PermitEmptyPasswords no ClientAliveInterval 180 -X11Forwarding {{ "yes" if sshd_enable_x11_forwarding else "no" }} +X11Forwarding {{ "yes" if sshd__enable_x11_forwarding else "no" }} {% if ansible_distribution == "Debian" %} Subsystem sftp /usr/lib/openssh/sftp-server -- cgit v1.2.3