2022-05-02 14:39:00 +02:00
|
|
|
---
|
|
|
|
- name: Install systemd service files
|
2024-02-06 09:43:37 +01:00
|
|
|
when:
|
|
|
|
- sshd_install_service | bool
|
|
|
|
- ansible_facts['service_mgr'] == 'systemd' or
|
|
|
|
(ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '7')
|
2022-05-02 14:39:00 +02:00
|
|
|
block:
|
|
|
|
- name: Install service unit file
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.template:
|
2022-05-02 14:39:00 +02:00
|
|
|
src: "{{ sshd_service_template_service }}"
|
|
|
|
dest: "/etc/systemd/system/{{ sshd_service }}.service"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
2024-06-21 10:12:02 +02:00
|
|
|
notify: Reload_sshd
|
2023-10-30 17:51:44 +01:00
|
|
|
|
2022-05-02 14:39:00 +02:00
|
|
|
- name: Install instanced service unit file
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.template:
|
2022-05-02 14:39:00 +02:00
|
|
|
src: "{{ sshd_service_template_at_service }}"
|
|
|
|
dest: "/etc/systemd/system/{{ sshd_service }}@.service"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
2024-06-21 10:12:02 +02:00
|
|
|
notify: Reload_sshd
|
2023-10-30 17:51:44 +01:00
|
|
|
when:
|
|
|
|
- __sshd_socket_accept | bool
|
|
|
|
|
2022-05-02 14:39:00 +02:00
|
|
|
- name: Install socket unit file
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.template:
|
2022-05-02 14:39:00 +02:00
|
|
|
src: "{{ sshd_service_template_socket }}"
|
|
|
|
dest: "/etc/systemd/system/{{ sshd_service }}.socket"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
2024-06-21 10:12:02 +02:00
|
|
|
notify: Reload_sshd
|
2022-05-02 14:39:00 +02:00
|
|
|
|
|
|
|
- name: Service enabled and running
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.service:
|
2022-05-02 14:39:00 +02:00
|
|
|
name: "{{ sshd_service }}"
|
|
|
|
enabled: true
|
|
|
|
state: started
|
|
|
|
when:
|
|
|
|
- sshd_manage_service|bool
|
2024-01-22 16:17:38 +01:00
|
|
|
- ansible_facts['virtualization_type'] | default(None) not in __sshd_skip_virt_env
|
2022-05-02 14:39:00 +02:00
|
|
|
- ansible_connection != 'chroot'
|
|
|
|
|
|
|
|
# Due to ansible bug 21026, cannot use service module on RHEL 7
|
|
|
|
- name: Enable service in chroot
|
2022-09-07 10:33:33 +02:00
|
|
|
ansible.builtin.command: systemctl enable {{ sshd_service }} # noqa command-instead-of-module
|
2022-05-02 14:39:00 +02:00
|
|
|
when:
|
|
|
|
- ansible_connection == 'chroot'
|
2023-08-05 12:01:19 +02:00
|
|
|
- ansible_facts['os_family'] == 'RedHat'
|
2024-01-22 16:17:38 +01:00
|
|
|
- ansible_facts['distribution_major_version'] | int >= 7
|
2023-04-10 22:19:29 +02:00
|
|
|
changed_when: true
|