mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 18:29:21 +00:00 
			
		
		
		
	Solved database backup buck
This commit is contained in:
		| @@ -50,25 +50,6 @@ | ||||
| - name: "include seed-database-to-backup.yml" | ||||
|   include_tasks: seed-database-to-backup.yml | ||||
|  | ||||
| - 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 | ||||
|  | ||||
| - name: run the backup_docker_to_local tasks once | ||||
|   set_fact: | ||||
|     run_once_backup_docker_to_local: true | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| # This file is also used by docker-matrix-compose | ||||
|  | ||||
| - name: Display all database variables | ||||
| - name: "{{ role_name }} | Display all database variables" | ||||
|   debug: | ||||
|     msg: | | ||||
|       database_instance: "{{ database_instance | default('undefined') }}" | ||||
| @@ -9,7 +9,7 @@ | ||||
|       database_password: "{{ database_password | default('undefined') }}" | ||||
|   when: enable_debug | bool | ||||
|  | ||||
| - name: fail if not all required database variables are defined | ||||
| - name: "{{ role_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: > | ||||
| @@ -22,12 +22,31 @@ | ||||
|      database_username is defined and | ||||
|      database_password is defined) | ||||
|  | ||||
| - name: seed database values | ||||
| - name: "{{ role_name }} | seed database values in directory {{ backup_docker_to_local_folder }}" | ||||
|   command: | ||||
|     cmd: "python database_entry_seeder.py databases.csv {{database_instance}} {{database_name}} {{database_username}} {{database_password}}" | ||||
|     chdir: "{{backup_docker_to_local_folder}}" | ||||
|     chdir: "{{ backup_docker_to_local_folder }}" | ||||
|   when: > | ||||
|     database_instance is defined and | ||||
|     database_name is defined and | ||||
|     database_username is defined and | ||||
|     database_password 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 | ||||
| @@ -1,22 +1,27 @@ | ||||
| - name: "{{ role_name }} | Load database variables" | ||||
|   include_vars: "{{ item }}" | ||||
|   loop: | ||||
|     - "{{ docker_var_file }}"   # Important to load docker variables first so that database can use them | ||||
|     - "{{ database_var_file }}" # Important to load them before docker role so that backup can use them | ||||
|  | ||||
| # Docker Routines | ||||
| - name: "include docker-compose role" | ||||
| - name: "{{ role_name }} | Include docker-compose role" | ||||
|   include_role:  | ||||
|     name: docker-compose | ||||
|  | ||||
| # Database Routines | ||||
| - name: "load variables from {{ role_path }}/vars/database.yml for whole play" | ||||
|   include_vars: "{{ role_path }}/vars/database.yml" | ||||
|  | ||||
| # The following env file will just be used from the dedicated mariadb container | ||||
| # and not the central-mariadb-database | ||||
| - name: "create {{database_env}}" | ||||
| - name: "{{ role_name }} | Create {{database_env}}" | ||||
|   template:  | ||||
|     src: "env/{{database_type}}.env.j2" | ||||
|     dest: "{{database_env}}" | ||||
|   notify: docker compose project build and setup | ||||
|   when: not applications[application_id].database.central_storage | bool | ||||
|  | ||||
| - name: create central database | ||||
| - name: "{{ role_name }} | Create central database" | ||||
|   include_role: | ||||
|     name: "docker-{{database_type}}" | ||||
|   when: applications[application_id].database.central_storage | bool | ||||
|   when: applications[application_id].database.central_storage | bool | ||||
|  | ||||
| - name: "{{ role_name }} | Add database to backup" | ||||
|   include_tasks: "{{ playbook_dir }}/roles/backup-docker-to-local/tasks/seed-database-to-backup.yml" | ||||
							
								
								
									
										2
									
								
								roles/docker-central-database/vars/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								roles/docker-central-database/vars/main.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| database_var_file:  "{{ role_path }}/vars/database.yml" | ||||
| docker_var_file:    "{{playbook_dir}}/roles/docker-compose/vars/docker-compose.yml" | ||||
| @@ -1,7 +1,7 @@ | ||||
| - name: "load variables from {{ role_path }}/vars/docker-compose.yml for whole play" | ||||
| - name: "{{ role_name }} | Load variables from {{ role_path }}/vars/docker-compose.yml for whole play" | ||||
|   include_vars: "{{ role_path }}/vars/docker-compose.yml" | ||||
|  | ||||
| - name: "remove {{ docker_compose.directories.instance }} and all its contents" | ||||
| - name: "{{ role_name }} | Remove {{ docker_compose.directories.instance }} and all its contents" | ||||
|   file: | ||||
|     path: "{{ docker_compose.directories.instance }}" | ||||
|     state: absent | ||||
| @@ -9,7 +9,7 @@ | ||||
|  | ||||
| # This could lead to problems in docker-compose directories which are based on a git repository | ||||
| # @todo Verify that this isn't the case. E.g. in accounting | ||||
| - name: "Create all docker-compose directories (including parent directories)" | ||||
| - name: "{{ role_name }} | Create all docker-compose directories (including parent directories)" | ||||
|   file: | ||||
|     path: "{{ item.value }}" | ||||
|     state: directory | ||||
|   | ||||
| @@ -7,7 +7,7 @@ database_password:  	                              "{{applications.nextcloud.cre | ||||
| database_type:                                      "mariadb"                                                     # Database flavor | ||||
|  | ||||
| # Networking | ||||
| domain:                                             "{{domains[application_id]}}"                                 # Public domain at which Nextcloud will be accessable | ||||
| domain:                                             "{{ domains[application_id] }}"                                 # Public domain at which Nextcloud will be accessable | ||||
| http_port:                                          "{{ ports.localhost.http[application_id] }}"                  # Port at which nextcloud is reachable in the local network | ||||
|  | ||||
| # Control Node | ||||
|   | ||||
		Reference in New Issue
	
	Block a user