|
1 | 1 | --- |
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}} |
4 | 16 |
|
5 | 17 | - name: create sshd_config and set permissions to root/600 |
6 | 18 | template: src='opensshd.conf.j2' dest='/etc/ssh/sshd_config' mode=0600 owner=root group=root validate="/usr/sbin/sshd -T -f %s" |
|
34 | 46 | changed_when: false |
35 | 47 | check_mode: no |
36 | 48 |
|
| 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 | + |
37 | 64 | - block: # only runs when selinux is running |
38 | 65 | - name: install selinux dependencies when selinux is installed on RHEL or Oracle Linux |
39 | 66 | yum: name="{{item}}" state=installed |
|
0 commit comments