diff --git a/defaults/main.yaml b/defaults/main.yaml index d342715..cd7edfb 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -4,7 +4,7 @@ sshd_config_path: /etc/ssh ssh_port: 22 ssh_address_family: any -ssh_listen_addresses: +ssh_listen_addresses: - 0.0.0.0 ssh_host_key_file: /etc/ssh/ssh_host_ed25519_key @@ -35,10 +35,10 @@ ssh_x11_forwarding: 'no' ssh_print_motd: 'no' -ssh_permit_user_env: False +ssh_permit_user_env: false ssh_accept_env: - LANG - 'LC_*' -ssh_banner: True +ssh_banner: true ssh_banner_file: /etc/issue.net diff --git a/tasks/main.yaml b/tasks/main.yaml index ef7e14c..5b37698 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -1,7 +1,7 @@ --- - name: Ensure ssh server is installed - package: + ansible.builtin.package: name: openssh-server state: present diff --git a/tasks/template_config.yaml b/tasks/template_config.yaml index 33ca2f3..3291702 100644 --- a/tasks/template_config.yaml +++ b/tasks/template_config.yaml @@ -1,26 +1,29 @@ --- - name: Ensure destination for sshd_config exists - file: + ansible.builtin.file: path: "{{ sshd_config_path }}" + mode: '0644' state: directory - name: Write sshd_config file - template: - src: ../templates/sshd_config.j2 + ansible.builtin.template: + src: sshd_config.j2 dest: "{{ sshd_config_path }}/sshd_config" + mode: '0644' become: true register: sshd_config_file - name: Restart service - systemd: + ansible.builtin.systemd: name: sshd - enabled: yes + enabled: true state: restarted when: sshd_config_file.changed - name: Write banner file - template: - src: ../templates/issue.net.j2 + ansible.builtin.template: + src: issue.net.j2 dest: "{{ ssh_banner_file }}" + mode: '0644' when: ssh_banner