-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprovision-docker-service.yml
More file actions
94 lines (84 loc) · 3.37 KB
/
Copy pathprovision-docker-service.yml
File metadata and controls
94 lines (84 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
- name: Preliminary System Checks
hosts: all
gather_facts: no
tasks:
- name: Verify if target system is a Linux System
ansible.builtin.script: '../../PCSMenu/src/Functions/Scripts/checkLinux.sh'
register: proxmox_check
ignore_errors: yes
- name: Halt if any target system is not a Linux System
ansible.builtin.fail:
msg: 'One or more targeted systems are not a System of Linux. Process halted.'
when: proxmox_check is failed
- name: Update & Upgrade Packages
become: yes
ansible.builtin.shell: |
apt-get update &&
apt-get upgrade -y
- name: Configuration and Cleanup
hosts: all
become: yes
vars_files:
- /opt/Wolflith/Temp/provisioning_docker_service_vars.yml
tasks:
- name: Docker Network and Directory Setup
block:
- name: Create Docker Network in the Linux Machine
ansible.builtin.shell: |
docker network create {{ network_name }}
ignore_errors: yes
- name: Ensure Host Destination Directory Exists
ansible.builtin.file:
path: '/home/docker/{{ selected_service }}'
state: directory
mode: '0755'
- name: Transfer Scripts and Configuration Files to Linux Host
ansible.builtin.copy:
src: '{{ item.src }}'
dest: '{{ item.dest }}'
mode: '0755'
loop:
- {
src: '/opt/Wolflith/PCSMenu/src/Functions/Docker/Scripts/updateDockerComposeEnv.sh',
dest: '/tmp/updateDockerComposeEnv.sh',
}
- {
src: '/opt/Wolflith/Temp/provisioning_docker_service_vars.yml',
dest: '/tmp/provisioning_docker_service_vars.yml',
}
- {
src: '{{ selected_service_path }}/docker-compose.yml',
dest: '/home/docker/{{ selected_service }}/docker-compose.yml',
}
- {
src: '{{ selected_service_path }}/.env',
dest: '/home/docker/{{ selected_service }}/.env',
}
- name: Check and Transfer Config Folder to Linux Host
ansible.builtin.copy:
src: '{{ selected_service_path }}/config'
dest: '/home/docker/{{ selected_service }}/config'
mode: '0755'
remote_src: yes
when: '"config" in lookup("ansible.builtin.fileglob", "{{ selected_service_path }}/config/*", wantlist=True)'
- name: Script Execution and Docker Service Deployment
block:
- name: Set Execute Permission for the Script Inside LXC Container
ansible.builtin.shell: |
chmod +x /tmp/updateDockerComposeEnv.sh
- name: Execute Script Inside LXC to Generate .env File
ansible.builtin.shell: |
bash -c "cd /tmp && ./updateDockerComposeEnv.sh {{ selected_service }}"
- name: Deploy Docker Compose Service Inside LXC Container
ansible.builtin.shell: |
bash -c "cd /home/docker/{{ selected_service }} && docker compose up -d"
- name: Cleanup Temporary Files and Directories
block:
- name: Remove Temporary Files from Linux Host
ansible.builtin.file:
path: '{{ item }}'
state: absent
loop:
- '/tmp/updateDockerComposeEnv.sh'
- '/tmp/provisioning_docker_service_vars.yml'