1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_sshd.git synced 2024-08-16 11:59:49 +02:00
ansible_role_sshd/tasks/main.yml

50 lines
1.3 KiB
YAML
Raw Normal View History

---
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
- name: Gather the package facts
package_facts:
manager: auto
failed_when: false
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
- 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 }}'
- name: "get package version of {{ sshd__package }}"
debug:
msg: "{{ ansible_facts.packages[sshd__package][0].version }}"
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
- include_tasks: keys.yml
2020-04-13 17:59:47 +02:00
2020-08-05 16:33:38 +02:00
- name: Create sshd configuration
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:
- systemctl restart ssh