--- - name: Check if Timeshift is installed ansible.builtin.command: timeshift --version register: timeshift_check failed_when: false changed_when: false - name: Install Timeshift ansible.builtin.apt: name: timeshift state: present become: true when: - timeshift_install | default(true) | bool - timeshift_check.rc != 0 - name: Create Timeshift snapshot directory ansible.builtin.file: path: "{{ timeshift_snapshot_location }}" state: directory mode: '0755' become: true when: timeshift_install | default(true) | bool - name: Create snapshot before playbook execution ansible.builtin.command: > timeshift --create --comments "{{ timeshift_snapshot_description }}" --tags {{ timeshift_snapshot_tags | join(',') }} --scripted become: true register: timeshift_snapshot_result when: - timeshift_auto_snapshot | default(true) | bool - timeshift_check.rc == 0 or timeshift_install | default(true) | bool changed_when: "'Snapshot created successfully' in timeshift_snapshot_result.stdout or 'Created snapshot' in timeshift_snapshot_result.stdout" failed_when: > timeshift_snapshot_result.rc != 0 and "'already exists' not in timeshift_snapshot_result.stderr | default('')" and "'Snapshot created' not in timeshift_snapshot_result.stderr | default('')" ignore_errors: true - name: Display snapshot information ansible.builtin.debug: msg: - "Timeshift snapshot operation completed" - "Output: {{ timeshift_snapshot_result.stdout | default('Check with: sudo timeshift --list') }}" - "To list snapshots: sudo timeshift --list" - "To restore: sudo timeshift --restore --snapshot 'SNAPSHOT_NAME'" when: - timeshift_auto_snapshot | default(true) | bool - timeshift_snapshot_result is defined