mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Shorted backup- to bkp-
This commit is contained in:
58
roles/bkp-docker-to-local/tasks/main.yml
Normal file
58
roles/bkp-docker-to-local/tasks/main.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
- name: "pkgmgr install"
|
||||
include_role:
|
||||
name: pkgmgr-install
|
||||
vars:
|
||||
package_name: bkp-docker-to-local
|
||||
when: run_once_backup_docker_to_local is not defined
|
||||
|
||||
- name: Retrieve bkp-docker-to-local path from pkgmgr
|
||||
command: pkgmgr path bkp-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 bkp-docker-to-local-everything.cymais.service
|
||||
template:
|
||||
src: bkp-docker-to-local-everything.service.j2
|
||||
dest: /etc/systemd/system/bkp-docker-to-local-everything.cymais.service
|
||||
notify: reload bkp-docker-to-local-everything.cymais.service
|
||||
when: run_once_backup_docker_to_local is not defined
|
||||
|
||||
- name: configure bkp-docker-to-local.cymais.service
|
||||
template:
|
||||
src: bkp-docker-to-local.service.j2
|
||||
dest: /etc/systemd/system/bkp-docker-to-local.cymais.service
|
||||
notify: reload bkp-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 generic-timer for {{service_name}}"
|
||||
include_role:
|
||||
name: generic-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
|
60
roles/bkp-docker-to-local/tasks/seed-database-to-backup.yml
Normal file
60
roles/bkp-docker-to-local/tasks/seed-database-to-backup.yml
Normal file
@@ -0,0 +1,60 @@
|
||||
# This file is also used by web-app-matrix
|
||||
|
||||
- name: "Display all database variables"
|
||||
debug:
|
||||
msg: |
|
||||
database_application_id: "{{ database_application_id | default('undefined') }}"
|
||||
database_instance: "{{ database_instance | default('undefined') }}"
|
||||
database_name: "{{ database_name | default('undefined') }}"
|
||||
database_type: "{{ database_type | default('undefined') }}"
|
||||
database_host: "{{ database_host | default('undefined') }}"
|
||||
database_username: "{{ database_username | default('undefined') }}"
|
||||
database_password: "{{ database_password | default('undefined') }}"
|
||||
when: enable_debug | bool
|
||||
|
||||
- name: "fail if not all required database variables are defined"
|
||||
fail:
|
||||
msg: "You must define all of the following variables: database_instance, database_name, database_username, database_password"
|
||||
when: >
|
||||
(database_instance is defined or
|
||||
database_name is defined or
|
||||
database_username is defined or
|
||||
database_password is defined) and not
|
||||
(database_instance is defined and
|
||||
database_name is defined and
|
||||
database_username is defined and
|
||||
database_password is defined)
|
||||
|
||||
- name: "seed database values in directory {{ backup_docker_to_local_folder }}"
|
||||
command: >
|
||||
python database_entry_seeder.py databases.csv
|
||||
"{{ database_instance }}"
|
||||
"{{ database_name }}"
|
||||
"{{ database_username }}"
|
||||
"{{ database_password }}"
|
||||
args:
|
||||
chdir: "{{ backup_docker_to_local_folder }}"
|
||||
when:
|
||||
- database_instance is defined
|
||||
- database_name is defined
|
||||
- database_username is defined
|
||||
- database_password is defined
|
||||
|
||||
- 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: >
|
||||
(database_instance is defined and
|
||||
database_name is defined and
|
||||
database_username is defined and
|
||||
database_password is defined) and
|
||||
run_once_backup_docker_to_local_file_permission is not defined
|
||||
register: file_permission_result
|
||||
|
||||
- name: run the backup_docker_to_local_file_permission tasks once
|
||||
set_fact:
|
||||
run_once_backup_docker_to_local_file_permission: true
|
||||
when: run_once_backup_docker_to_local_file_permission is not defined and file_permission_result is defined and file_permission_result.changed
|
Reference in New Issue
Block a user