ansible-sshd/tasks/install_config.yml
Matt Willsher d4eae954c1
feat: Ubuntu noble (#290)
* feat: Add support for Ubuntu Nobel/24.04 LTS
* fix: Add missing PrintMotd to Ubuntu 22.04
* fix(tests): Various linting fixes

---------
Co-authored-by: Jakub Jelen <jjelen@redhat.com>
2024-06-21 09:12:02 +01:00

49 lines
1.7 KiB
YAML

---
- name: Create a directory for drop-in configuration snippets
ansible.builtin.file:
path: "{{ sshd_config_file | dirname }}"
state: directory
mode: "{{ sshd_drop_in_dir_mode }}"
when:
- sshd_main_config_file is not none
- sshd_config_file | dirname == sshd_main_config_file ~ '.d'
- name: Create the complete configuration file
ansible.builtin.template:
src: sshd_config.j2
dest: "{{ sshd_config_file }}"
owner: "{{ sshd_config_owner }}"
group: "{{ sshd_config_group }}"
mode: "{{ sshd_config_mode }}"
validate: >-
{% if not __sshd_supports_validate %}
true %s
{% elif sshd_test_hostkey is defined and sshd_test_hostkey.path is defined %}
{{ sshd_binary }} -t -f %s -h {{ sshd_test_hostkey.path }}/rsa_key
{% else %}
{{ sshd_binary }} -t -f %s
{% endif %}
backup: "{{ sshd_backup }}"
notify: Reload_sshd
- name: Make sure the include path is present in the main sshd_config
ansible.builtin.lineinfile:
insertbefore: BOF
line: "Include {{ sshd_config_file | dirname }}/*.conf"
path: "{{ sshd_main_config_file }}"
owner: "{{ sshd_config_owner }}"
group: "{{ sshd_config_group }}"
mode: "{{ sshd_config_mode }}"
validate: >-
{% if not __sshd_supports_validate %}
true %s
{% elif sshd_test_hostkey is defined and sshd_test_hostkey.path is defined %}
{{ sshd_binary }} -t -f %s -h {{ sshd_test_hostkey.path }}/rsa_key
{% else %}
{{ sshd_binary }} -t -f %s
{% endif %}
backup: "{{ sshd_backup }}"
notify: Reload_sshd
when:
- sshd_main_config_file is not none
- sshd_config_file | dirname == sshd_main_config_file ~ '.d'