-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshot-restore.yml
23 lines (23 loc) · 1.09 KB
/
snapshot-restore.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- name: Restore snapshot
hosts: snapshotted
become: true
tasks:
- name: Check if snapshot exists
ansible.builtin.stat:
path: /timeshift/snapshots/by-ansible
register: check_status
- name: Start snapshot restore in background
ansible.builtin.shell:
cmd: "yes '' | timeshift --scripted --snapshot-device /dev/mapper/{{ inventory_hostname }}--vg-root --restore --snapshot by-ansible --yes"
executable: /bin/bash
# start timeshift restore in background, as it will reboot the system by itself
async: 1200 # 20 minutes should be enough
poll: 0 # if the command fails, we will get stuck here
when: check_status.stat.exists
changed_when: true # we always change something here
- name: Wait for system reboot # wait for the restore and reboot the system
ansible.builtin.reboot:
reboot_command: "sleep 1" # we will not trigger the reboot ourselves, as timeshift will do it
msg: "Reboot by timeshift every moment now..."
connect_timeout: 10 # to allow faster reconnects
when: check_status.stat.exists