00_core.ymlΒΆ

---
- include_tasks: utils/once/flag.yml

- name: πŸ“‚ Include dependencies
  include_role:
    name: "{{ svc_bkp_volume_2_local_dependency }}"
  loop:
    - sys-svc-container
    - sys-lock
    - user-backup
    - sys-ctl-alm-compose
    - sys-ctl-cln-bkps
  loop_control:
    loop_var: svc_bkp_volume_2_local_dependency

- include_tasks: 01_install.yml
  when: run_once_svc_bkp_volume_2_local_install is not defined

- name: "♻️ reset (if enabled) for {{ role_name}}"
  include_tasks: 02_reset.yml
  when: MODE_RESET | bool

- name: βœ… Ensure databases.csv exists (root only)
  ansible.builtin.file:
    path: "{{ FILE_DATABASE_SECRETS }}"
    state: touch
    owner: root
    group: root
    mode: "0600"
    modification_time: preserve
    access_time: preserve

- name: βœ… Ensure compositions dir exists (baudolo scans it; absent on fresh host)
  ansible.builtin.file:
    path: "{{ DIR_COMPOSITIONS }}"
    state: directory

- name: βœ… Assert the configured snapshot_mode names a snapshot mode
  ansible.builtin.assert:
    that:
      - BKP_VOLUME_2_LOCAL_SNAPSHOT_MODE in BKP_VOLUME_2_LOCAL_SNAPSHOT_MODES
    fail_msg: >-
      services.volume-2-local.snapshot_mode is '{{ BKP_VOLUME_2_LOCAL_SNAPSHOT_MODE_RAW }}', which
      resolves to '{{ BKP_VOLUME_2_LOCAL_SNAPSHOT_MODE }}' and is not one of
      {{ BKP_VOLUME_2_LOCAL_SNAPSHOT_MODES | join(', ') }}. Quote the value: YAML reads a bare
      on/yes/true as a boolean.
    quiet: true

- name: πŸ“¦ Install the btrfs tools the snapshot launcher shells out to
  become: true
  package_install: # nocheck: package-install only on hosts with a btrfs mount
    id: btrfs-tools
  when: ansible_facts.mounts | selectattr('fstype', 'equalto', 'btrfs') | list | length > 0

- include_tasks: 04_snapshot_subject.yml
  when: BKP_VOLUME_2_LOCAL_SNAPSHOT_MODE != 'never'

- name: "πŸ“ create {{ BKP_VOLUME_2_LOCAL_SNAPSHOT_BIN }}"
  ansible.builtin.copy:
    src: python/baudolo_snapshot.py
    dest: "{{ BKP_VOLUME_2_LOCAL_SNAPSHOT_BIN }}"
    owner: root
    group: root
    mode: "0755"

- name: "▢️ Execute system service setup for '{{ system_service_id }}'"
  include_role:
    name: sys-service
  vars:
    system_service_copy_files: false
    system_service_timer_enabled: true
    system_service_force_linear_sync: true
    system_service_force_flush_instant: "{{ MODE_BACKUP | bool }}"
    system_service_force_flush_final: false
    system_service_state: "{{ 'started' if MODE_BACKUP | bool else omit }}"
    system_service_on_calendar: "{{ SYS_SCHEDULE_BACKUP_CONTAINER_TO_LOCAL }}"
    system_service_tpl_exec_start_pre: '{{ BIN_LOCK }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(" ")  }} --ignore {{ SYS_SERVICE_BACKUP_VOLUME_2_LOCAL }} --timeout
      "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
    system_service_tpl_exec_start: "/bin/sh -c '{{ BKP_VOLUME_2_LOCAL_EXEC }}'"
    system_service_tpl_on_failure: "{{ SYS_SERVICE_ON_FAILURE_COMPOSE }}"