blob: 9345e9c65dd00fd1c96b4f734e82063a0e5a39a1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
- name: Get host distro
ansible.builtin.setup:
gather_subset:
- distribution
- distribution_major_version
- distribution_release
- os_family
- name: Set platform-specific variables
ansible.builtin.include_vars: "{{ __sshd_vars_file }}"
loop:
- "{{ ansible_facts['os_family'] }}.yml"
- "{{ ansible_facts['distribution'] }}.yml"
- "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
vars:
__sshd_vars_file: "{{ role_path }}/vars/{{ item }}"
when: __sshd_vars_file is exists
- name: Configure sshd
become: true
ansible.builtin.template:
src: sshd_config.j2
dest: /etc/ssh/sshd_config
owner: root
group: root
mode: '644'
validate: /usr/sbin/sshd -t -f %s
register: sshd_conf
- name: Restart sshd
become: true
when: sshd_conf is changed
ansible.builtin.systemd_service:
name: '{{ __sshd_service_name }}'
state: restarted
- name: Enable sshd service
become: true
ansible.builtin.systemd_service:
name: '{{ __sshd_service_name }}.service'
enabled: true
|