2020-10-06 21:13:58 +02:00
|
|
|
---
|
2023-04-10 22:19:29 +02:00
|
|
|
- name: Test sysconfig
|
|
|
|
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:
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: "Backup configuration files"
|
2022-06-05 09:54:56 +02:00
|
|
|
ansible.builtin.include_tasks: tasks/backup.yml
|
2020-11-20 23:12:04 +01:00
|
|
|
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: Configure sshd
|
2022-06-05 09:54:56 +02:00
|
|
|
ansible.builtin.include_role:
|
2021-04-07 20:12:03 +02:00
|
|
|
name: ansible-sshd
|
|
|
|
vars:
|
|
|
|
sshd_sysconfig: true
|
|
|
|
sshd_sysconfig_override_crypto_policy: true
|
|
|
|
sshd_sysconfig_use_strong_rng: 32
|
2020-10-06 21:13:58 +02:00
|
|
|
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: Verify the options are correctly set
|
2023-04-10 22:19:29 +02:00
|
|
|
tags: tests::verify
|
|
|
|
when:
|
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
|
|
|
- ansible_facts['distribution'] != 'Fedora'
|
2024-01-22 16:17:38 +01:00
|
|
|
- ansible_facts['distribution_major_version'] | int < 9
|
2021-04-07 20:12:03 +02:00
|
|
|
block:
|
2022-06-05 09:54:56 +02:00
|
|
|
- name: Flush handlers
|
|
|
|
ansible.builtin.meta: flush_handlers
|
2020-10-06 21:13:58 +02:00
|
|
|
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: Print current configuration file
|
2022-06-05 09:54:56 +02:00
|
|
|
ansible.builtin.slurp:
|
2021-04-07 20:12:03 +02:00
|
|
|
src: /etc/sysconfig/sshd
|
|
|
|
register: config
|
2020-10-06 21:13:58 +02:00
|
|
|
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: Evaluate sysconfig similarly as systemd
|
2022-06-05 09:54:56 +02:00
|
|
|
ansible.builtin.shell: |
|
2021-04-07 20:12:03 +02:00
|
|
|
set -eu
|
|
|
|
if set -o | grep pipefail 2>&1 /dev/null ; then
|
|
|
|
set -o pipefail
|
|
|
|
fi
|
|
|
|
source /etc/sysconfig/sshd
|
|
|
|
echo "CP=|${CRYPTO_POLICY:-}|"
|
|
|
|
echo "RNG=|${SSH_USE_STRONG_RNG:-}|"
|
|
|
|
register: evaluation
|
|
|
|
changed_when: false
|
2020-12-04 16:37:12 +01:00
|
|
|
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: Evaluate sysconfig similarly as systemd on RHEL 8
|
2022-06-05 09:54:56 +02:00
|
|
|
ansible.builtin.shell: |
|
2021-04-07 20:12:03 +02:00
|
|
|
set -eu
|
|
|
|
if set -o | grep pipefail 2>&1 /dev/null ; then
|
|
|
|
set -o pipefail
|
|
|
|
fi
|
|
|
|
source /etc/crypto-policies/back-ends/opensshserver.config
|
|
|
|
source /etc/sysconfig/sshd
|
|
|
|
echo "CP=|${CRYPTO_POLICY:-}|"
|
|
|
|
echo "RNG=|${SSH_USE_STRONG_RNG:-}|"
|
|
|
|
register: evaluation8
|
|
|
|
changed_when: false
|
|
|
|
when:
|
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
|
|
|
- ansible_facts['distribution_major_version'] == "8"
|
2020-12-04 16:37:12 +01:00
|
|
|
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: Check the crypto policies is overridden in RHEL 8
|
2022-06-05 09:54:56 +02:00
|
|
|
ansible.builtin.assert:
|
2021-04-07 20:12:03 +02:00
|
|
|
that:
|
|
|
|
- "'CRYPTO_POLICY=' in config.content | b64decode"
|
|
|
|
# these are string variants in default configuration file
|
|
|
|
- "'# CRYPTO_POLICY=' not in config.content | b64decode"
|
|
|
|
- "'CP=||' in evaluation8.stdout"
|
|
|
|
when:
|
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
|
|
|
- ansible_facts['distribution_major_version'] == "8"
|
2020-11-05 00:31:06 +01:00
|
|
|
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: Check the RNG options are in configuration file
|
2022-06-05 09:54:56 +02:00
|
|
|
ansible.builtin.assert:
|
2021-04-07 20:12:03 +02:00
|
|
|
that:
|
|
|
|
- "'SSH_USE_STRONG_RNG=32' in config.content | b64decode"
|
|
|
|
# these are string variants in default configuration file
|
|
|
|
- "'SSH_USE_STRONG_RNG=0' not in config.content | b64decode"
|
|
|
|
- "'# SSH_USE_STRONG_RNG=1' not in config.content | b64decode"
|
|
|
|
- "'RNG=|32|' in evaluation.stdout"
|
2020-11-20 23:12:04 +01:00
|
|
|
|
2021-04-07 20:12:03 +02:00
|
|
|
- name: "Restore configuration files"
|
2022-06-05 09:54:56 +02:00
|
|
|
ansible.builtin.include_tasks: tasks/restore.yml
|