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

create support for openssh below version 8

This commit is contained in:
L3D 2020-08-05 16:29:34 +02:00 committed by L3D
parent 50f3287641
commit 7f717b33cd
No known key found for this signature in database
GPG key ID: 5215C3441797AB2B
4 changed files with 17 additions and 8 deletions

View file

@ -5,8 +5,7 @@
- name: Gather the package facts
package_facts:
manager: auto
- include_tasks: packages.yml
failed_when: false
- name: set sshd_service variable
block:
@ -16,6 +15,8 @@
- name: read default variable
include_vars: vars/sshd_default.yml
- include_tasks: packages.yml
- name: Collect all users and groups allowed to login via ssh
set_fact:
sshd__allowed_users: '{{ sshd__allowed_users + users.keys() | default({}) | sort }}'
@ -24,11 +25,17 @@
- name: "get package version of {{ sshd__package }}"
debug:
msg: "{{ ansible_facts.packages[sshd__package][0].version }}"
when: "'{{ sshd__package }}' in ansible_facts.packages"
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', '>=')
- include_tasks: keys.yml
- name: Copy sshd configuration
- name: Create sshd configuration (for sshd > 8)
become: yes
template:
src: sshd_config.j2

View file

@ -1,6 +1,6 @@
---
- name: "install {{ sshd__package }}"
- name: install openssh server
become: true
package:
name: "{{ sshd__package }}"
state: "{{ sshd_state }}"
state: "{{ sshd__state }}"

View file

@ -1,10 +1,12 @@
# Attention, local changew will be overwritten
# MIT (C) L3D
# MIT (C) L3D <l3d@c3woc.de>
# {{ ansible_managed }}
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
{% if sshd__version_is_above_eight | bool %}
Include /etc/ssh/sshd_config.d/*.conf
{% endif %}
# Networking
Port {{ sshd__port }}

View file

@ -1,3 +1,3 @@
---
playbook_version_number: 2075 # should be over ninethousand
playbook_version_number: 2079 # should be over ninethousand
playbook_version_path: 'role-sshd_chaos-bodensee_github.com.version'