forked from linux-system-roles/ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests_backup.yml
More file actions
54 lines (46 loc) · 1.6 KB
/
tests_backup.yml
File metadata and controls
54 lines (46 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
- name: Test backups
hosts: all
vars:
__ssh_test_backup_files:
- /etc/ssh/ssh_config
- /etc/ssh/ssh_config.d/00-ansible.conf
tasks:
- name: Backup configuration files
ansible.builtin.include_tasks: tasks/backup.yml
- name: Find old backups files
ansible.builtin.find:
paths: "{{ main_ssh_config_path }}"
patterns: "{{ main_ssh_config_name }}.*@*~"
register: backup_files
- name: Remove old backup files
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
with_items: "{{ backup_files.files }}"
- name: Configure ssh without creating backup
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
ssh_backup: false
- name: Find new backups files
ansible.builtin.find:
paths: "{{ main_ssh_config_path }}"
patterns: "{{ main_ssh_config_name }}.*@*~"
register: no_backup
- name: Configure ssh again with different configuration and with backup
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
ssh_ForwardX11Trusted: 'yes' # noqa var-naming
register: second_run
- name: Find new backups files again
ansible.builtin.find:
paths: "{{ main_ssh_config_path }}"
patterns: "{{ main_ssh_config_name }}.*@*~"
register: new_backup
- name: Verify backup was not done in first, but in second attempt
ansible.builtin.assert:
that:
- no_backup.files == []
- new_backup.files != []
- name: Restore configuration files
ansible.builtin.include_tasks: tasks/restore.yml