Another big round of refactoring and cleaning...

This commit is contained in:
2025-07-11 17:55:26 +02:00
parent aa61bf2a44
commit 168c5c0da6
323 changed files with 761 additions and 811 deletions

View File

@@ -0,0 +1,56 @@
- name: "pkgmgr install"
include_role:
name: pkgmgr-install
vars:
package_name: "{{ bkp_docker_to_local_pkg }}"
when: run_once_bkp_docker_to_local is not defined
- name: "Retrieve {{ bkp_docker_to_local_pkg }} path from pkgmgr"
command: "pkgmgr path {{ bkp_docker_to_local_pkg }}"
register: pkgmgr_output
changed_when: false
when: run_once_bkp_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_bkp_docker_to_local is not defined
- name: "reset (if enabled)"
include_tasks: reset.yml
when: mode_reset | bool and run_once_bkp_docker_to_local is not defined
- name: configure sys-bkp-docker-to-local-everything.cymais.service
template:
src: sys-bkp-docker-to-local-everything.service.j2
dest: /etc/systemd/system/sys-bkp-docker-to-local-everything.cymais.service
notify: reload sys-bkp-docker-to-local-everything.cymais.service
when: run_once_bkp_docker_to_local is not defined
- name: configure sys-bkp-docker-to-local.cymais.service
template:
src: sys-bkp-docker-to-local.service.j2
dest: /etc/systemd/system/sys-bkp-docker-to-local.cymais.service
notify: reload sys-bkp-docker-to-local.cymais.service
when: run_once_bkp_docker_to_local is not defined
- name: "set 'service_name' to '{{ role_name }}'"
set_fact:
service_name: "{{ role_name }}"
when: run_once_bkp_docker_to_local is not defined
- name: "include role for sys-timer for {{service_name}}"
include_role:
name: sys-timer
vars:
on_calendar: "{{on_calendar_backup_docker_to_local}}"
when: run_once_bkp_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_bkp_docker_to_local: true
when: run_once_bkp_docker_to_local is not defined

View File

@@ -0,0 +1,4 @@
- name: "reset {{ backup_docker_to_local_folder }}databases.csv"
file:
path: "{{ backup_docker_to_local_folder }}databases.csv"
state: absent

View 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_bkp_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_bkp_docker_to_local_file_permission: true
when: run_once_bkp_docker_to_local_file_permission is not defined and file_permission_result is defined and file_permission_result.changed