2018-03-07 03:28:23 +01:00
|
|
|
---
|
2019-05-15 11:44:17 +02:00
|
|
|
- include_tasks: versioncheck.yml
|
2019-05-17 12:50:48 +02:00
|
|
|
when: submodules_versioncheck|bool
|
2018-11-16 11:44:36 +01:00
|
|
|
|
2020-08-05 15:22:13 +02:00
|
|
|
- name: Gather the package facts
|
|
|
|
package_facts:
|
|
|
|
manager: auto
|
2020-08-05 16:29:34 +02:00
|
|
|
failed_when: false
|
2020-08-05 15:22:13 +02:00
|
|
|
|
2020-03-17 15:39:07 +01:00
|
|
|
- name: set sshd_service variable
|
|
|
|
block:
|
|
|
|
- name: read os specific variable
|
2020-03-27 00:12:00 +01:00
|
|
|
include_vars: "vars/sshd_{{ ansible_distribution | lower }}.yml"
|
2020-03-17 15:39:07 +01:00
|
|
|
rescue:
|
|
|
|
- name: read default variable
|
2020-03-27 00:12:00 +01:00
|
|
|
include_vars: vars/sshd_default.yml
|
2018-11-16 11:44:36 +01:00
|
|
|
|
2020-08-05 16:29:34 +02:00
|
|
|
- include_tasks: packages.yml
|
|
|
|
|
2020-03-18 11:30:48 +01:00
|
|
|
- name: Collect all users and groups allowed to login via ssh
|
|
|
|
set_fact:
|
2020-08-04 15:07:02 +02:00
|
|
|
sshd__allowed_users: '{{ sshd__allowed_users + users.keys() | default({}) | sort }}'
|
|
|
|
sshd__allowed_groups: '{{ sshd__allowed_groups + users.keys() | default({}) | sort }}'
|
2018-03-16 04:54:02 +01:00
|
|
|
|
2020-08-05 15:22:13 +02:00
|
|
|
- name: "get package version of {{ sshd__package }}"
|
|
|
|
debug:
|
|
|
|
msg: "{{ ansible_facts.packages[sshd__package][0].version }}"
|
2020-08-05 16:29:34 +02:00
|
|
|
when: sshd__package in ansible_facts.packages
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: set fact sshd__version_is_above_eight
|
|
|
|
set_fact:
|
|
|
|
sshd__version_is_above_eight: true
|
|
|
|
when: ansible_facts.packages[sshd__package][0].version is version('8.0', '>=')
|
2018-11-16 11:44:36 +01:00
|
|
|
|
2020-08-05 15:22:13 +02:00
|
|
|
- include_tasks: keys.yml
|
2020-04-13 17:59:47 +02:00
|
|
|
|
2020-08-05 16:29:34 +02:00
|
|
|
- name: Create sshd configuration (for sshd > 8)
|
2020-04-13 17:59:47 +02:00
|
|
|
become: yes
|
|
|
|
template:
|
|
|
|
src: sshd_config.j2
|
|
|
|
dest: '/etc/ssh/sshd_config'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 'u=rw,g=r,o=r'
|
|
|
|
validate: /usr/sbin/sshd -t -f %s
|
|
|
|
backup: yes
|
|
|
|
notify:
|
2020-08-05 15:22:13 +02:00
|
|
|
- systemctl restart ssh
|