2022-08-17 14:05:06 +02:00
|
|
|
---
|
2023-04-10 22:19:29 +02:00
|
|
|
- name: Test duplicates - setup config1
|
|
|
|
hosts: all
|
2022-08-17 14:05:06 +02:00
|
|
|
vars:
|
|
|
|
sshd_config_file: /etc/ssh/dup_config1
|
2022-08-20 22:23:36 +02:00
|
|
|
__sshd_test_backup_files:
|
|
|
|
- /etc/ssh/dup_config1
|
|
|
|
- /etc/ssh/dup_config2
|
|
|
|
- /etc/ssh/sshd_config
|
2022-08-17 14:05:06 +02:00
|
|
|
tasks:
|
|
|
|
- name: "Backup configuration files"
|
|
|
|
ansible.builtin.include_tasks: tasks/backup.yml
|
|
|
|
|
|
|
|
- name: Configure config1
|
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: ansible-sshd
|
|
|
|
|
2023-04-10 22:19:29 +02:00
|
|
|
- name: Test duplicates - default config
|
|
|
|
hosts: all
|
2022-08-17 14:05:06 +02:00
|
|
|
tasks:
|
2022-08-17 19:29:16 +02:00
|
|
|
- name: Configure default config
|
2022-08-17 14:05:06 +02:00
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: ansible-sshd
|
|
|
|
|
2023-04-10 22:19:29 +02:00
|
|
|
- name: Test duplicates - setup config2
|
|
|
|
hosts: all
|
2022-08-17 14:05:06 +02:00
|
|
|
vars:
|
|
|
|
sshd_config_file: /etc/ssh/dup_config2
|
|
|
|
tasks:
|
|
|
|
- name: Configure config2
|
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: ansible-sshd
|
2022-08-19 18:36:01 +02:00
|
|
|
public: true
|
2022-08-17 14:05:06 +02:00
|
|
|
|
2022-08-19 18:44:23 +02:00
|
|
|
- name: Convert exported variable to fact so that it is available in next plays
|
2023-04-10 22:19:29 +02:00
|
|
|
ansible.builtin.set_fact:
|
2022-08-19 18:44:23 +02:00
|
|
|
__sshd_config_file: "{{ __sshd_config_file }}"
|
|
|
|
|
2023-04-10 22:19:29 +02:00
|
|
|
- name: Test duplicate - verify results
|
|
|
|
hosts: all
|
2022-08-17 14:05:06 +02:00
|
|
|
tasks:
|
|
|
|
- name: Get config1 stat
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: /etc/ssh/dup_config1
|
|
|
|
register: config1_stat
|
|
|
|
|
|
|
|
- name: Check config1 exists
|
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
2022-08-17 17:31:00 +02:00
|
|
|
- config1_stat.stat.exists
|
2022-08-17 14:05:06 +02:00
|
|
|
|
|
|
|
- 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:
|
2022-08-17 17:31:00 +02:00
|
|
|
- default_config_stat.stat.exists
|
2022-08-17 14:05:06 +02:00
|
|
|
|
|
|
|
- name: Get config2 stat
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: "{{ __sshd_config_file }}"
|
|
|
|
register: config2_stat
|
|
|
|
|
|
|
|
- name: Check config2 exists
|
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
2022-08-17 17:31:00 +02:00
|
|
|
- config2_stat.stat.exists
|
2022-08-17 14:05:06 +02:00
|
|
|
|
|
|
|
- name: "Restore configuration files"
|
|
|
|
ansible.builtin.include_tasks: tasks/restore.yml
|