computer-playbook/roles/backup-docker-to-local/tasks/main.yml

54 lines
2.0 KiB
YAML

- name: install pandas system wide
community.general.pacman:
name:
- lsof
- python-pandas
state: present
when: run_once_backup_docker_to_local is not defined
- name: pull backup-docker-to-local.git
git:
repo: "https://github.com/kevinveenbirkenbach/backup-docker-to-local.git"
dest: "{{backup_docker_to_local_folder}}"
update: yes
register: git_result
ignore_errors: true
when: run_once_backup_docker_to_local is not defined
- name: Warn if repo is not reachable
debug:
msg: "Warning: Repository is not reachable."
when: git_result is defined and git_result.failed is defined and run_once_cleanup_failed_docker_backups is not defined
- name: configure backup-docker-to-local.service
template:
src: backup-docker-to-local.service.j2
dest: /etc/systemd/system/backup-docker-to-local.service
notify: reload backup-docker-to-local.service
when: run_once_backup_docker_to_local is not defined
- name: configure backup-docker-to-local.timer.tpl
template: src=backup-docker-to-local.timer.j2 dest=/etc/systemd/system/backup-docker-to-local.timer
register: backup_docker_to_local_timer
changed_when: backup_docker_to_local_timer.changed or activate_all_timers | bool
notify: restart backup-docker-to-local.timer
when: run_once_backup_docker_to_local is not defined
- name: seed database values
command:
cmd: "python database_entry_seeder.py databases.csv {{database_instance}} {{database_host}} {{database_databasename}} {{database_username}} {{database_password}}"
chdir: "{{backup_docker_to_local_folder}}"
- name: Set file permissions for databases.csv to be readable, writable, and executable by root only
ansible.builtin.file:
path: "{{ backup_docker_to_local_folder }}databases.csv"
mode: '0700'
owner: root
group: root
when: run_once_backup_docker_to_local is not defined
- 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