mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 02:10:05 +00:00 
			
		
		
		
	Optimized docker2local variables and constants
This commit is contained in:
		| @@ -1,9 +1,9 @@ | ||||
| - name: "reload sys-bkp-docker-2-loc-everything service" | ||||
| - name: "reload backup docker to local (all) service" | ||||
|   systemd: | ||||
|     name: sys-bkp-docker-2-loc-everything{{ SYS_SERVICE_SUFFIX }} | ||||
|     name: {{ BKP_DOCKER_2_LOC_SERVICE_ALL }} | ||||
|     daemon_reload: yes | ||||
|  | ||||
| - name: "reload sys-bkp-docker-2-loc service" | ||||
| - name: "reload backup docker to local service" | ||||
|   systemd: | ||||
|     name: sys-bkp-docker-2-loc{{ SYS_SERVICE_SUFFIX }} | ||||
|     name: {{ BKP_DOCKER_2_LOC_SERVICE }} | ||||
|     daemon_reload: yes | ||||
| @@ -14,17 +14,17 @@ | ||||
|   include_tasks: 03_reset.yml | ||||
|   when: MODE_RESET | bool | ||||
|  | ||||
| - name: configure sys-bkp-docker-2-loc-everything service | ||||
| - name: "setup '{{ BKP_DOCKER_2_LOC_SERVICE_ALL }}'" | ||||
|   template: | ||||
|     src: sys-bkp-docker-2-loc-everything.service.j2 | ||||
|     dest: /etc/systemd/system/sys-bkp-docker-2-loc-everything{{ SYS_SERVICE_SUFFIX }} | ||||
|   notify: reload sys-bkp-docker-2-loc-everything service | ||||
|     src: "{{ role_name }}-everything.service.j2" | ||||
|     dest: /etc/systemd/system/{{ BKP_DOCKER_2_LOC_SERVICE_ALL }} | ||||
|   notify: reload backup docker to local (all) service | ||||
|  | ||||
| - name: configure sys-bkp-docker-2-loc{{ SYS_SERVICE_SUFFIX }} | ||||
| - name: "setup '{{ BKP_DOCKER_2_LOC_SERVICE }}'" | ||||
|   template: | ||||
|     src: sys-bkp-docker-2-loc.service.j2 | ||||
|     dest: /etc/systemd/system/sys-bkp-docker-2-loc{{ SYS_SERVICE_SUFFIX }} | ||||
|   notify: reload sys-bkp-docker-2-loc service | ||||
|     src: "{{ role_name }}.service.j2" | ||||
|     dest: /etc/systemd/system/{{ BKP_DOCKER_2_LOC_SERVICE }} | ||||
|   notify: reload backup docker to local service | ||||
|  | ||||
| - name: "set 'service_name' to '{{ role_name }}'" | ||||
|   set_fact: | ||||
|   | ||||
| @@ -1,12 +1,12 @@ | ||||
| - block: | ||||
|     - name: "pkgmgr install {{ bkp_docker_2_loc_pkg }}" | ||||
|     - name: "pkgmgr install {{ BKP_DOCKER_2_LOC_PKG }}" | ||||
|       include_role: | ||||
|         name: pkgmgr-install | ||||
|       vars: | ||||
|         package_name: "{{ bkp_docker_2_loc_pkg }}" | ||||
|         package_name: "{{ BKP_DOCKER_2_LOC_PKG }}" | ||||
|  | ||||
|     - name: "Retrieve {{ bkp_docker_2_loc_pkg }} path from pkgmgr" | ||||
|       command: "pkgmgr path {{ bkp_docker_2_loc_pkg }}" | ||||
|     - name: "Retrieve {{ BKP_DOCKER_2_LOC_PKG }} path from pkgmgr" | ||||
|       command: "pkgmgr path {{ BKP_DOCKER_2_LOC_PKG }}" | ||||
|       register: pkgmgr_output | ||||
|       changed_when: false | ||||
|  | ||||
| @@ -16,4 +16,4 @@ | ||||
|       changed_when: false | ||||
|   when: backup_docker_to_local_folder is not defined | ||||
|   vars: | ||||
|     bkp_docker_2_loc_pkg: backup-docker-to-local | ||||
|     BKP_DOCKER_2_LOC_PKG: backup-docker-to-local | ||||
|   | ||||
| @@ -55,10 +55,10 @@ | ||||
|     database_name is defined and | ||||
|     database_username is defined and | ||||
|     database_password is defined) and | ||||
|     run_once_bkp_docker_2_loc_file_permission is not defined | ||||
|     run_once_sys_bkp_docker_2_loc_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_2_loc_file_permission: true | ||||
|   when: run_once_bkp_docker_2_loc_file_permission is not defined and file_permission_result is defined and file_permission_result.changed | ||||
|     run_once_sys_bkp_docker_2_loc_file_permission: true | ||||
|   when: run_once_sys_bkp_docker_2_loc_file_permission is not defined and file_permission_result is defined and file_permission_result.changed | ||||
| @@ -7,4 +7,4 @@ | ||||
| - name: "include 04_seed-database-to-backup.yml" | ||||
|   include_tasks: 04_seed-database-to-backup.yml | ||||
|   when: | ||||
|     - bkp_docker_2_loc_db_enabled | bool | ||||
|     - BKP_DOCKER_2_LOC_DB_ENABLED | bool | ||||
|   | ||||
| @@ -4,6 +4,6 @@ OnFailure=sys-alm-compose.{{ SOFTWARE_NAME }}@%n.service sys-cln-faild-bkps{{ SY | ||||
|  | ||||
| [Service] | ||||
| Type=oneshot | ||||
| ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ system_maintenance_services | join(' ')  }} --ignore {{ system_maintenance_backup_services | reject('equalto', 'sys-bkp-docker-2-loc') | join(' ') }} --timeout "{{system_maintenance_lock_timeout_backup_services}}"' | ||||
| ExecStart=/bin/sh -c '{{ bkp_docker_2_loc_exec }} --everything' | ||||
| ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ system_maintenance_services | join(' ')  }} --ignore {{ system_maintenance_backup_services | reject('equalto', role_name ) | join(' ') }} --timeout "{{system_maintenance_lock_timeout_backup_services}}"' | ||||
| ExecStart=/bin/sh -c '{{ BKP_DOCKER_2_LOC_EXEC }} --everything' | ||||
| ExecStartPost=/bin/sh -c '/bin/systemctl start sys-rpr-docker-soft{{ SYS_SERVICE_SUFFIX }} &' | ||||
| @@ -4,6 +4,6 @@ OnFailure=sys-alm-compose.{{ SOFTWARE_NAME }}@%n.service sys-cln-faild-bkps{{ SY | ||||
|  | ||||
| [Service] | ||||
| Type=oneshot | ||||
| ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ system_maintenance_services | join(' ')  }} --ignore {{ system_maintenance_backup_services | reject('equalto', 'sys-bkp-docker-2-loc-everything') | join(' ') }} --timeout "{{system_maintenance_lock_timeout_backup_services}}"' | ||||
| ExecStart=/bin/sh -c '{{ bkp_docker_2_loc_exec }}' | ||||
| ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ system_maintenance_services | join(' ')  }} --ignore {{ system_maintenance_backup_services | reject('equalto', role_name ~ '-everything') | join(' ') }} --timeout "{{system_maintenance_lock_timeout_backup_services}}"' | ||||
| ExecStart=/bin/sh -c '{{ BKP_DOCKER_2_LOC_EXEC }}' | ||||
| ExecStartPost=/bin/sh -c '/bin/systemctl start sys-rpr-docker-soft{{ SYS_SERVICE_SUFFIX }} &' | ||||
| @@ -1,46 +1,50 @@ | ||||
| # Mapping logic for backup-docker-to-local CLI arguments | ||||
| # | ||||
| # - bkp_docker_2_loc_database_routine:    All service names where backup.database_routine is set (for --database-containers) | ||||
| # - bkp_docker_2_loc_no_stop_required:    All images where backup.no_stop_required is set (for --images-no-stop-required) | ||||
| # - bkp_docker_2_loc_disabled:            All images where backup.disabled is set (for --images-no-backup-required) | ||||
| # - BKP_DOCKER_2_LOC_DB_ROUTINE:       All service names where backup.database_routine is set (for --database-containers) | ||||
| # - BKP_DOCKER_2_LOC_NO_STOP_REQUIRED: All images where backup.no_stop_required is set (for --images-no-stop-required) | ||||
| # - BKP_DOCKER_2_LOC_DISABLED:         All images where backup.disabled is set (for --images-no-backup-required) | ||||
| # CLI-ready variables render these lists as argument strings. | ||||
|  | ||||
| BKP_DOCKER_2_LOC_SERVICE:     "{{ role_name ~ SYS_SERVICE_SUFFIX }}" | ||||
|  | ||||
| BKP_DOCKER_2_LOC_SERVICE_ALL: "{{ role_name }}-everything{{ SYS_SERVICE_SUFFIX }}" | ||||
|  | ||||
| # Verify if DB is enabled | ||||
| bkp_docker_2_loc_db_enabled: "{{ database_type | default('') | bool }}" | ||||
| BKP_DOCKER_2_LOC_DB_ENABLED: "{{ database_type | default('') | bool }}" | ||||
|  | ||||
| # Gather mapped values as lists | ||||
| bkp_docker_2_loc_database_routine: >- | ||||
| BKP_DOCKER_2_LOC_DB_ROUTINE: >- | ||||
|   {{ applications | find_dock_val_by_bkp_entr('database_routine', 'name') | list }} | ||||
|  | ||||
| bkp_docker_2_loc_no_stop_required: >- | ||||
| BKP_DOCKER_2_LOC_NO_STOP_REQUIRED: >- | ||||
|   {{ applications | find_dock_val_by_bkp_entr('no_stop_required', 'image') | list }} | ||||
|  | ||||
| bkp_docker_2_loc_disabled: >- | ||||
| BKP_DOCKER_2_LOC_DISABLED: >- | ||||
|   {{ applications | find_dock_val_by_bkp_entr('disabled', 'image') | list }} | ||||
|  | ||||
| # CLI argument strings (only set if list not empty) | ||||
| bkp_docker_2_loc_database_routine_cli: >- | ||||
|   {% if bkp_docker_2_loc_database_routine | length > 0 -%} | ||||
|     --database-containers {{ bkp_docker_2_loc_database_routine | join(' ') }} | ||||
| BKP_DOCKER_2_LOC_DB_ROUTINE_CLI: >- | ||||
|   {% if BKP_DOCKER_2_LOC_DB_ROUTINE | length > 0 -%} | ||||
|     --database-containers {{ BKP_DOCKER_2_LOC_DB_ROUTINE | join(' ') }} | ||||
|   {%- endif %} | ||||
|  | ||||
| bkp_docker_2_loc_no_stop_required_cli: >- | ||||
|   {% if bkp_docker_2_loc_no_stop_required | length > 0 -%} | ||||
|     --images-no-stop-required {{ bkp_docker_2_loc_no_stop_required | join(' ') }} | ||||
| BKP_DOCKER_2_LOC_NO_STOP_REQUIRED_CLI: >- | ||||
|   {% if BKP_DOCKER_2_LOC_NO_STOP_REQUIRED | length > 0 -%} | ||||
|     --images-no-stop-required {{ BKP_DOCKER_2_LOC_NO_STOP_REQUIRED | join(' ') }} | ||||
|   {%- endif %} | ||||
|  | ||||
| bkp_docker_2_loc_disabled_cli: >- | ||||
|   {% if bkp_docker_2_loc_disabled | length > 0 -%} | ||||
|     --images-no-backup-required {{ bkp_docker_2_loc_disabled | join(' ') }} | ||||
| BKP_DOCKER_2_LOC_DISABLED_CLI: >- | ||||
|   {% if BKP_DOCKER_2_LOC_DISABLED | length > 0 -%} | ||||
|     --images-no-backup-required {{ BKP_DOCKER_2_LOC_DISABLED | join(' ') }} | ||||
|   {%- endif %} | ||||
|  | ||||
| # List of CLI args for convenience (e.g. for looping or joining) | ||||
| bkp_docker_2_loc_cli_args_list: | ||||
|   - "{{ bkp_docker_2_loc_database_routine_cli }}" | ||||
|   - "{{ bkp_docker_2_loc_no_stop_required_cli }}" | ||||
|   - "{{ bkp_docker_2_loc_disabled_cli }}" | ||||
| BKP_DOCKER_2_LOC_CLI_ARGS_LIST: | ||||
|   - "{{ BKP_DOCKER_2_LOC_DB_ROUTINE_CLI }}" | ||||
|   - "{{ BKP_DOCKER_2_LOC_NO_STOP_REQUIRED_CLI }}" | ||||
|   - "{{ BKP_DOCKER_2_LOC_DISABLED_CLI }}" | ||||
|  | ||||
| bkp_docker_2_loc_exec: >- | ||||
| BKP_DOCKER_2_LOC_EXEC: >- | ||||
|   /usr/bin/python {{ backup_docker_to_local_folder }}backup-docker-to-local.py | ||||
|   --compose-dir {{ PATH_DOCKER_COMPOSE_INSTANCES }} | ||||
|   {{ bkp_docker_2_loc_cli_args_list | select('string') | join(' ') }} | ||||
|   {{ BKP_DOCKER_2_LOC_CLI_ARGS_LIST | select('string') | join(' ') }} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user