--- # Copyright (c) 2022, Gregory Furlong # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later - name: Create a snapshot, erroring if one already exists at path block: - name: Create a snapshot named 'snapshot_error' community.general.btrfs_subvolume: automount: Yes filesystem_label: "{{ btrfs_subvolume_target_label }}" name: "/snapshot_error" snapshot_source: "/" snapshot_conflict: "error" state: "present" register: result - name: Snapshot 'snapshot_error' created ansible.builtin.assert: that: - result is changed - name: Create a snapshot named 'snapshot_error' (no idempotency) community.general.btrfs_subvolume: automount: Yes filesystem_label: "{{ btrfs_subvolume_target_label }}" name: "/snapshot_error" snapshot_source: "/" snapshot_conflict: "error" state: "present" register: result ignore_errors: true - name: Snapshot 'snapshot_error' created (no idempotency) ansible.builtin.assert: that: - result is not changed - name: Cleanup created snapshot community.general.btrfs_subvolume: automount: Yes filesystem_label: "{{ btrfs_subvolume_target_label }}" name: "/snapshot_error" state: "absent"