2020-10-06 21:13:58 +02:00
|
|
|
---
|
|
|
|
- hosts: all
|
2020-11-20 23:12:04 +01:00
|
|
|
vars:
|
|
|
|
__sshd_test_backup_files:
|
|
|
|
- /etc/ssh/sshd_config
|
|
|
|
- /etc/ssh/sshd_config.d/00-ansible_system_role.conf
|
|
|
|
- /etc/sysconfig/sshd
|
2020-10-06 21:13:58 +02:00
|
|
|
tasks:
|
2020-11-20 23:12:04 +01:00
|
|
|
- name: "Backup configuration files"
|
|
|
|
include_tasks: tasks/backup.yml
|
|
|
|
|
2020-10-06 21:13:58 +02:00
|
|
|
- name: Configure sshd
|
|
|
|
include_role:
|
|
|
|
name: ansible-sshd
|
|
|
|
vars:
|
|
|
|
sshd_sysconfig: true
|
|
|
|
sshd_sysconfig_override_crypto_policy: true
|
|
|
|
sshd_sysconfig_use_strong_rng: 32
|
|
|
|
|
|
|
|
- name: Verify the options are correctly set
|
|
|
|
block:
|
|
|
|
- meta: flush_handlers
|
|
|
|
|
|
|
|
- name: Print current configuration file
|
2020-11-13 13:14:22 +01:00
|
|
|
slurp:
|
|
|
|
src: /etc/sysconfig/sshd
|
2020-10-06 21:13:58 +02:00
|
|
|
register: config
|
|
|
|
|
2020-11-05 00:31:06 +01:00
|
|
|
- name: Check the crypto policies is overridden in RHEL 8
|
2020-10-06 21:13:58 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2020-11-13 13:14:22 +01:00
|
|
|
- "'CRYPTO_POLICY=' in config.content | b64decode"
|
2020-10-06 21:13:58 +02:00
|
|
|
# these are string variants in default configuration file
|
2020-11-13 13:14:22 +01:00
|
|
|
- "'# CRYPTO_POLICY=' not in config.content | b64decode"
|
2020-11-05 00:31:06 +01:00
|
|
|
when:
|
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
|
|
|
- ansible_facts['distribution_major_version'] == "8"
|
|
|
|
|
|
|
|
- name: Check the RNG options are in configuration file
|
|
|
|
assert:
|
|
|
|
that:
|
2020-11-13 13:14:22 +01:00
|
|
|
- "'SSH_USE_STRONG_RNG=32' in config.content | b64decode"
|
2020-11-05 00:31:06 +01:00
|
|
|
# these are string variants in default configuration file
|
2020-11-13 13:14:22 +01:00
|
|
|
- "'SSH_USE_STRONG_RNG=0' not in config.content | b64decode"
|
|
|
|
- "'# SSH_USE_STRONG_RNG=1' not in config.content | b64decode"
|
2020-10-06 21:13:58 +02:00
|
|
|
tags: tests::verify
|
2020-11-23 15:24:52 +01:00
|
|
|
when:
|
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
|
|
|
- ansible_facts['distribution'] != 'Fedora'
|
2020-11-20 23:12:04 +01:00
|
|
|
|
|
|
|
- name: "Restore configuration files"
|
|
|
|
include_tasks: tasks/restore.yml
|