Migrate services part
This commit is contained in:
		
							parent
							
								
									7c59e4ae57
								
							
						
					
					
						commit
						73bce8f6e5
					
				
					 157 changed files with 3883 additions and 9 deletions
				
			
		
							
								
								
									
										16
									
								
								roles/backup/tasks/backup.d.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								roles/backup/tasks/backup.d.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| --- | ||||
| - name: Set backup.d path | ||||
|   ansible.builtin.set_fact: | ||||
|     backup_d_path: "{{ (service_path, 'backup.d') | path_join }}" | ||||
| - name: Create backup.d directory | ||||
|   ansible.builtin.file: | ||||
|     path: "{{ backup_d_path }}" | ||||
|     state: directory | ||||
|     mode: "0755" | ||||
| - name: Copy the additional backup scripts | ||||
|   ansible.builtin.copy: | ||||
|     src: "{{ item }}" | ||||
|     dest: "{{ backup_d_path }}" | ||||
|     mode: "0755" | ||||
|   with_fileglob: | ||||
|     - "{{ ansible_facts.hostname }}/*" | ||||
							
								
								
									
										12
									
								
								roles/backup/tasks/docker.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								roles/backup/tasks/docker.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | |||
| --- | ||||
| - name: Copy the Dockerfile | ||||
|   ansible.builtin.copy: | ||||
|     src: Dockerfile | ||||
|     dest: "{{ (service_path, 'Dockerfile') | path_join }}" | ||||
|     mode: "0644" | ||||
|   register: cmd_result | ||||
| 
 | ||||
| - name: Set the docker rebuild flag | ||||
|   ansible.builtin.set_fact: | ||||
|     docker_rebuild: true | ||||
|   when: cmd_result.changed # noqa: no-handler We need to handle the restart per service. Handlers don't support variables. | ||||
							
								
								
									
										39
									
								
								roles/backup/tasks/main.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								roles/backup/tasks/main.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| --- | ||||
| - name: Set common facts | ||||
|   ansible.builtin.import_tasks: tasks/set-default-facts.yml | ||||
| 
 | ||||
| - name: Deploy {{ svc.name }} | ||||
|   vars: | ||||
|     svc: "{{ backup_svc }}" | ||||
|     env: "{{ backup_env }}" | ||||
|     compose: "{{ backup_compose }}" | ||||
|   block: | ||||
|     - name: Import prepare tasks for common service | ||||
|       ansible.builtin.import_tasks: tasks/prepare-common-service.yml | ||||
| 
 | ||||
|     - name: Copy the main backup script | ||||
|       ansible.builtin.template: | ||||
|         src: "backup.sh.j2" | ||||
|         dest: "{{ (service_path, 'backup.sh') | path_join }}" | ||||
|         mode: "0755" | ||||
| 
 | ||||
|     - name: Import tasks specific to docker | ||||
|       ansible.builtin.import_tasks: docker.yml | ||||
|     - name: Import tasks specific to the backup.d scripts | ||||
|       ansible.builtin.import_tasks: backup.d.yml | ||||
|     - name: Import tasks specific to systemd | ||||
|       ansible.builtin.import_tasks: systemd.yml | ||||
| 
 | ||||
|     - name: Build service | ||||
|       ansible.builtin.command: | ||||
|         cmd: docker compose build --pull | ||||
|         chdir: "{{ service_path }}" | ||||
|       register: cmd_result | ||||
|       when: docker_rebuild | ||||
|       changed_when: true | ||||
| 
 | ||||
|     - name: Verify service | ||||
|       ansible.builtin.command: | ||||
|         cmd: docker compose run --rm app check | ||||
|         chdir: "{{ service_path }}" | ||||
|       changed_when: false | ||||
							
								
								
									
										20
									
								
								roles/backup/tasks/systemd.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								roles/backup/tasks/systemd.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | |||
| --- | ||||
| - name: Copy the system service | ||||
|   ansible.builtin.template: | ||||
|     src: backup.service.j2 | ||||
|     dest: /etc/systemd/system/backup.service | ||||
|     mode: "0644" | ||||
|   become: true | ||||
| - name: Copy the system timer | ||||
|   ansible.builtin.copy: | ||||
|     src: backup.timer | ||||
|     dest: /etc/systemd/system/backup.timer | ||||
|     mode: "0644" | ||||
|   become: true | ||||
| - name: Enable the system timer | ||||
|   ansible.builtin.systemd_service: | ||||
|     name: backup.timer | ||||
|     state: started | ||||
|     enabled: true | ||||
|     daemon_reload: true | ||||
|   become: true | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue