2018-08-25 23:39:06 +02:00
|
|
|
---
|
2020-03-29 15:51:27 +02:00
|
|
|
- name: OS is supported
|
|
|
|
meta: end_host
|
|
|
|
when:
|
|
|
|
- not __sshd_os_supported|bool
|
2018-08-25 23:39:06 +02:00
|
|
|
|
|
|
|
- name: Install ssh packages
|
|
|
|
package:
|
2018-09-08 10:13:51 +02:00
|
|
|
name: "{{ sshd_packages }}"
|
2018-08-25 23:39:06 +02:00
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Configuration
|
|
|
|
template:
|
|
|
|
src: sshd_config.j2
|
|
|
|
dest: "{{ sshd_config_file }}"
|
|
|
|
owner: "{{ sshd_config_owner }}"
|
|
|
|
group: "{{ sshd_config_group }}"
|
|
|
|
mode: "{{ sshd_config_mode }}"
|
|
|
|
validate: "{{ sshd_binary }} -t -f %s"
|
2019-03-22 11:51:39 +01:00
|
|
|
backup: "{{ sshd_backup }}"
|
2018-08-25 23:39:06 +02:00
|
|
|
notify: reload_sshd
|
|
|
|
|
|
|
|
- name: Install systemd service files
|
|
|
|
block:
|
2019-05-23 19:31:30 +02:00
|
|
|
- name: Install service unit file
|
|
|
|
template:
|
2018-08-25 23:39:06 +02:00
|
|
|
src: "{{ sshd_service_template_service }}"
|
|
|
|
dest: "/etc/systemd/system/{{ sshd_service }}.service"
|
2020-09-18 21:49:22 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
2018-08-25 23:39:06 +02:00
|
|
|
notify: reload_sshd
|
2019-05-23 19:31:30 +02:00
|
|
|
- name: Install instanced service unit file
|
|
|
|
template:
|
2018-08-25 23:39:06 +02:00
|
|
|
src: "{{ sshd_service_template_at_service }}"
|
|
|
|
dest: "/etc/systemd/system/{{ sshd_service }}@.service"
|
2020-09-18 21:49:22 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
2018-08-25 23:39:06 +02:00
|
|
|
notify: reload_sshd
|
2019-05-23 19:31:30 +02:00
|
|
|
- name: Install socket unit file
|
|
|
|
template:
|
2018-08-25 23:39:06 +02:00
|
|
|
src: "{{ sshd_service_template_socket }}"
|
|
|
|
dest: "/etc/systemd/system/{{ sshd_service }}.socket"
|
2020-09-18 21:49:22 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
2018-08-25 23:39:06 +02:00
|
|
|
notify: reload_sshd
|
2019-05-23 19:37:09 +02:00
|
|
|
when: sshd_install_service|bool
|
2018-08-25 23:39:06 +02:00
|
|
|
|
|
|
|
- name: Service enabled and running
|
|
|
|
service:
|
|
|
|
name: "{{ sshd_service }}"
|
|
|
|
enabled: true
|
|
|
|
state: started
|
2018-09-11 15:10:58 +02:00
|
|
|
when:
|
2019-05-23 19:37:09 +02:00
|
|
|
- sshd_manage_service|bool
|
2018-09-11 15:10:58 +02:00
|
|
|
- ansible_virtualization_type|default(None) != 'docker'
|
|
|
|
- ansible_connection != 'chroot'
|
|
|
|
|
|
|
|
# Due to ansible bug 21026, cannot use service module on RHEL 7
|
|
|
|
- name: Enable service in chroot
|
2019-05-23 19:37:58 +02:00
|
|
|
command: systemctl enable {{ sshd_service }} # noqa 303
|
2018-09-11 15:10:58 +02:00
|
|
|
when:
|
|
|
|
- ansible_connection == 'chroot'
|
|
|
|
- ansible_os_family == 'RedHat'
|
|
|
|
- ansible_distribution_major_version|int >= 7
|
2018-08-25 23:39:06 +02:00
|
|
|
|
|
|
|
- name: Register that this role has run
|
2018-09-08 10:13:51 +02:00
|
|
|
set_fact:
|
|
|
|
sshd_has_run: true
|
2018-08-25 23:39:06 +02:00
|
|
|
when: sshd_has_run is not defined
|