Migrate services part
This commit is contained in:
		
							parent
							
								
									7c59e4ae57
								
							
						
					
					
						commit
						73bce8f6e5
					
				
					 157 changed files with 3883 additions and 9 deletions
				
			
		
							
								
								
									
										19
									
								
								roles/teamspeak_fallback/files/docker-compose.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								roles/teamspeak_fallback/files/docker-compose.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| services: | ||||
|   teamspeak: | ||||
|     image: teamspeak | ||||
|     restart: always | ||||
|     ports: | ||||
|       - 9987:9987/udp | ||||
|       - 10011:10011 | ||||
|       - 30033:30033 | ||||
|     environment: | ||||
|       TS3SERVER_DB_PLUGIN: ts3db_sqlite3 | ||||
|       TS3SERVER_DB_SQLCREATEPATH: create_sqlite | ||||
|       TS3SERVER_LICENSE: accept | ||||
|     volumes: | ||||
|       - data:/var/ts3server/ | ||||
| 
 | ||||
| volumes: | ||||
|   data: | ||||
|     external: true | ||||
|     name: teamspeak-fallback-data | ||||
							
								
								
									
										36
									
								
								roles/teamspeak_fallback/tasks/main.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								roles/teamspeak_fallback/tasks/main.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| --- | ||||
| - name: Set common facts | ||||
|   ansible.builtin.import_tasks: tasks/set-default-facts.yml | ||||
| 
 | ||||
| - name: Deploy {{ svc.name }} | ||||
|   vars: | ||||
|     svc: "{{ teamspeak_fallback_svc }}" | ||||
|   block: | ||||
|     - name: Import tasks to create service directory | ||||
|       ansible.builtin.import_tasks: tasks/steps/create-service-directory.yml | ||||
| 
 | ||||
|     - name: Copy the docker-compose file | ||||
|       ansible.builtin.copy: | ||||
|         src: docker-compose.yml | ||||
|         dest: "{{ (service_path, 'docker-compose.yml') | path_join }}" | ||||
|         mode: "0644" | ||||
| 
 | ||||
|     - name: Template the conditional-start script | ||||
|       ansible.builtin.template: | ||||
|         src: conditional-start.sh.j2 | ||||
|         dest: "{{ (service_path, 'conditional-start.sh') | path_join }}" | ||||
|         mode: "0755" | ||||
| 
 | ||||
|     - name: Copy the system service | ||||
|       ansible.builtin.template: | ||||
|         src: teamspeak-fallback.service.j2 | ||||
|         dest: /etc/systemd/system/teamspeak-fallback.service | ||||
|         mode: "0644" | ||||
|       become: true | ||||
|     - name: Enable the system service | ||||
|       ansible.builtin.systemd_service: | ||||
|         name: teamspeak-fallback.service | ||||
|         state: started | ||||
|         enabled: true | ||||
|         daemon_reload: true | ||||
|       become: true | ||||
							
								
								
									
										18
									
								
								roles/teamspeak_fallback/templates/conditional-start.sh.j2
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								roles/teamspeak_fallback/templates/conditional-start.sh.j2
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| #!/usr/bin/env sh | ||||
| 
 | ||||
| while true | ||||
| do | ||||
| 	if nc -z -w 3 "{{ teamspeak_fallback_check_server }}" "{{ teamspeak_fallback_check_port }}" | ||||
| 	then | ||||
| 		if docker compose ps --services | grep teamspeak >/dev/null; then | ||||
| 			echo "Stopping Server" | ||||
| 			docker compose down | ||||
| 		fi | ||||
| 	else | ||||
| 		if ! docker compose ps --services | grep teamspeak >/dev/null; then | ||||
| 			echo "Starting Server" | ||||
| 			docker compose up -d --pull=always | ||||
| 		fi | ||||
| 	fi | ||||
| 	sleep 2 | ||||
| done | ||||
|  | @ -0,0 +1,13 @@ | |||
| [Service] | ||||
| [Unit] | ||||
| Description=Teamspeak Fallback Starter | ||||
| After=network.target | ||||
| 
 | ||||
| [Service] | ||||
| Type=simple | ||||
| ExecStart={{ service_path }}/conditional-start.sh | ||||
| WorkingDirectory={{ service_path }} | ||||
| Restart=on-failure | ||||
| 
 | ||||
| [Install] | ||||
| WantedBy=multi-user.target | ||||
							
								
								
									
										6
									
								
								roles/teamspeak_fallback/vars/main.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								roles/teamspeak_fallback/vars/main.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | |||
| --- | ||||
| teamspeak_fallback_check_server: ts.sneiso.eu | ||||
| teamspeak_fallback_check_port: 30033 | ||||
| 
 | ||||
| teamspeak_fallback_svc: | ||||
|   name: teamspeak-fallback | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue