Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit 7a01bd0

Browse files
author
Sebastian Gumprich
committed
change hostkey setting
1 parent f8b8dfe commit 7a01bd0

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

tasks/main.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
---
2-
- name: add the OS specific variables
3-
include_vars: "{{ ansible_os_family }}.yml"
2+
- name: Set OS dependent variables
3+
include_vars: "{{ item }}"
4+
with_first_found:
5+
- "{{ ansible_distribution }}_{{ ansible_distribution_major_version }}.yml"
6+
- "{{ ansible_distribution }}.yml"
7+
- "{{ ansible_os_family }}_{{ ansible_distribution_major_version }}.yml"
8+
- "{{ ansible_os_family }}.yml"
9+
10+
- name: get openssh-version
11+
shell: ssh -V 2>&1 | perl -ne '/[\d\.]+/ && print $&'
12+
changed_when: false
13+
register: sshd_version
14+
15+
- debug: var={{sshd_version.stdout}}
416

517
- name: create sshd_config and set permissions to root/600
618
template: src='opensshd.conf.j2' dest='/etc/ssh/sshd_config' mode=0600 owner=root group=root validate="/usr/sbin/sshd -T -f %s"
@@ -34,6 +46,21 @@
3446
changed_when: false
3547
check_mode: no
3648

49+
- name: set hostkeys according to openssh-version
50+
set_fact:
51+
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key']
52+
when: sshd_version.stdout >= '5.3'
53+
54+
- name: set hostkeys according to openssh-version
55+
set_fact:
56+
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_ecdsa_key']
57+
when: sshd_version.stdout >= '6.0'
58+
59+
- name: set hostkeys according to openssh-version
60+
set_fact:
61+
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_ecdsa_key', '/etc/ssh/ssh_host_ed25519_key']
62+
when: sshd_version.stdout >= '6.3'
63+
3764
- block: # only runs when selinux is running
3865
- name: install selinux dependencies when selinux is installed on RHEL or Oracle Linux
3966
yum: name="{{item}}" state=installed

0 commit comments

Comments
 (0)