fixed ansible pull backups

pull/25/head
Cian Hatton 3 years ago
parent 62f3ee4316
commit 538ea01946

@ -33,3 +33,6 @@ backup: deps
restore: deps restore: deps
ansible-playbook playbooks/restore-docker-volumes.yml ansible-playbook playbooks/restore-docker-volumes.yml
cron:
ansible-playbook playbooks/setup-homelab.yml --tags cron

@ -23,7 +23,7 @@
become: true become: true
pre_tasks: pre_tasks:
- name: Include vault variables. - name: Include vault variables.
include_vars: '../{{vault_file}}' include_vars: '../{{ vault_file }}'
tags: [always] tags: [always]
roles: roles:
@ -42,7 +42,7 @@
pre_tasks: pre_tasks:
- name: Include vault variables. - name: Include vault variables.
include_vars: '../{{vault_file}}' include_vars: '../{{ vault_file }}'
tags: [always] tags: [always]
roles: roles:

@ -7,7 +7,7 @@
user: user:
name: ansible name: ansible
groups: root groups: root
system: true shell: /bin/bash
- name: Add ssh key for ansible - name: Add ssh key for ansible
authorized_key: authorized_key:

@ -105,16 +105,25 @@
state: present state: present
with_items: '{{services}}' with_items: '{{services}}'
- name: Install Ansible pull
tags: ["cron"]
ansible.builtin.pip:
name:
- ansible
# TODO: need to specify ansible pull directly, it doesn't find it when it's in PATH
- name: Ensure Nightly Cron Backups - name: Ensure Nightly Cron Backups
tags: ["cron"] tags: ["cron"]
ansible.builtin.cron: ansible.builtin.cron:
name: backup docker volumes (nightly) name: backup docker volumes (nightly)
weekday: "0" weekday: "0"
minute: "0" minute: "0"
hour: "3" hour: "4"
user: ansible user: "{{ homelab_user }}"
job: "ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=nightly >> /home/cianhatton/logs/nightly.log 2>&1" job: "/home/{{ homelab_user }}/.local/bin/ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=nightly >> ~/logs/nightly.log 2>&1"
cron_file: ansible_nightly_docker_volume_backup cron_file: ansible_nightly_docker_volume_backup
state: present
- name: Ensure Monthly Cron Backups - name: Ensure Monthly Cron Backups
tags: ["cron"] tags: ["cron"]
@ -122,6 +131,7 @@
name: backup docker volumes (monthly) name: backup docker volumes (monthly)
month: "*" month: "*"
day : "1" day : "1"
user: ansible user: "{{ homelab_user }}"
job: "ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=monthly >> /home/cianhatton/logs/monthly.log 2>&1" job: "/home/{{ homelab_user }}/.local/bin/ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=monthly >> ~/logs/monthly.log 2>&1"
cron_file: ansible_monthly_docker_volume_backup cron_file: ansible_monthly_docker_volume_backup
state: present

Loading…
Cancel
Save