ansible-sshd/tests/tests_duplicate_role.yml
Rich Megginson 70808e97fc ansible-lint - align with current Ansible recommendations
Use `true/false` instead of `yes/no`
Ensure use of FQCN for builtin modules
Use correct spacing in Jinja expressions
All tasks and plays must have a `name`, and the `name` string must begin with an uppercase letter
Use `ansible.posix.mount` instead of `ansible.builtin.mount`
Use `set -o pipefail` with `shell` module where supported by the platform shell

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2023-04-10 14:21:30 -06:00

73 lines
1.9 KiB
YAML

---
- name: Test duplicates - setup config1
hosts: all
vars:
sshd_config_file: /etc/ssh/dup_config1
__sshd_test_backup_files:
- /etc/ssh/dup_config1
- /etc/ssh/dup_config2
- /etc/ssh/sshd_config
tasks:
- name: "Backup configuration files"
ansible.builtin.include_tasks: tasks/backup.yml
- name: Configure config1
ansible.builtin.include_role:
name: ansible-sshd
- name: Test duplicates - default config
hosts: all
tasks:
- name: Configure default config
ansible.builtin.include_role:
name: ansible-sshd
- name: Test duplicates - setup config2
hosts: all
vars:
sshd_config_file: /etc/ssh/dup_config2
tasks:
- name: Configure config2
ansible.builtin.include_role:
name: ansible-sshd
public: true
- name: Convert exported variable to fact so that it is available in next plays
ansible.builtin.set_fact:
__sshd_config_file: "{{ __sshd_config_file }}"
- name: Test duplicate - verify results
hosts: all
tasks:
- name: Get config1 stat
ansible.builtin.stat:
path: /etc/ssh/dup_config1
register: config1_stat
- name: Check config1 exists
ansible.builtin.assert:
that:
- config1_stat.stat.exists
- name: Get default config stat
ansible.builtin.stat:
path: "{{ __sshd_config_file }}"
register: default_config_stat
- name: Check default config exists
ansible.builtin.assert:
that:
- default_config_stat.stat.exists
- name: Get config2 stat
ansible.builtin.stat:
path: "{{ __sshd_config_file }}"
register: config2_stat
- name: Check config2 exists
ansible.builtin.assert:
that:
- config2_stat.stat.exists
- name: "Restore configuration files"
ansible.builtin.include_tasks: tasks/restore.yml