ansible-sshd/tests/tests_duplicate_role.yml

70 lines
1.7 KiB
YAML
Raw Normal View History

2022-08-17 14:05:06 +02:00
---
- hosts: all
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
- hosts: all
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
- hosts: all
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
set_fact:
__sshd_config_file: "{{ __sshd_config_file }}"
2022-08-17 14:05:06 +02:00
- 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:
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