- name: "pkgmgr install"
  include_role:
    name: pkgmgr-install
  vars:
    package_name: backup-docker-to-local
  when: run_once_backup_docker_to_local is not defined

- name: Retrieve backup-docker-to-local path from pkgmgr
  command: pkgmgr path backup-docker-to-local
  register: pkgmgr_output
  changed_when: false
  when: run_once_backup_docker_to_local is not defined

- name: Set fact for backup_docker_to_local_folder
  set_fact:
    backup_docker_to_local_folder: "{{ pkgmgr_output.stdout }}/"
  changed_when: false
  when: run_once_backup_docker_to_local is not defined

- name: configure backup-docker-to-local-everything.cymais.service
  template: 
    src: backup-docker-to-local-everything.service.j2
    dest: /etc/systemd/system/backup-docker-to-local-everything.cymais.service
  notify: reload backup-docker-to-local-everything.cymais.service
  when: run_once_backup_docker_to_local is not defined

- name: configure backup-docker-to-local.cymais.service
  template: 
    src: backup-docker-to-local.service.j2
    dest: /etc/systemd/system/backup-docker-to-local.cymais.service
  notify: reload backup-docker-to-local.cymais.service
  when: run_once_backup_docker_to_local is not defined

- name: set service_name to the name of the current role
  set_fact:
    service_name: "{{ role_name }}"
  when: run_once_backup_docker_to_local is not defined

- name: "include role for systemd-timer for {{service_name}}"
  include_role:
    name: systemd-timer
  vars:
    on_calendar:  "{{on_calendar_backup_docker_to_local}}"
  when: run_once_backup_docker_to_local is not defined

- name: "reset {{ backup_docker_to_local_folder }}databases.csv"
  file:
    path: "{{ backup_docker_to_local_folder }}databases.csv"
    state: absent
  when: mode_reset | bool and run_once_backup_docker_to_local is not defined

- name: "include seed-database-to-backup.yml"
  include_tasks: seed-database-to-backup.yml

- name: run the backup_docker_to_local tasks once
  set_fact:
    run_once_backup_docker_to_local: true
  when: run_once_backup_docker_to_local is not defined
