/
/
/
Ansible role that deployes services on my runner machine
1---
2# Runner Services - Web Tools (Stirling-PDF, ConvertX, CyberChef, IT-Tools)
3
4- name: Create Web Tools configuration directories
5 file:
6 path: "{{ item }}"
7 state: directory
8 owner: "{{ runner_user }}"
9 group: "users"
10 mode: '2775'
11 loop:
12 - "{{ web_tools_config_dir }}"
13 - "{{ web_tools_data_dir }}/stirling-pdf/configs"
14 - "{{ web_tools_data_dir }}/stirling-pdf/logs"
15 - "{{ web_tools_data_dir }}/stirling-pdf/customFiles"
16 - "{{ web_tools_data_dir }}/stirling-pdf/pipeline"
17 - "{{ web_tools_data_dir }}/stirling-pdf/temp"
18 - "{{ web_tools_data_dir }}/convertx/data"
19
20- name: Generate Web Tools environment file
21 template:
22 src: web-tools.env.j2
23 dest: "{{ web_tools_config_dir }}/web-tools.env"
24 owner: "{{ runner_user }}"
25 group: "users"
26 mode: '0664'
27 notify: restart web-tools
28
29- name: Create Web Tools Docker Compose file
30 template:
31 src: web-tools-compose.yml.j2
32 dest: "{{ web_tools_config_dir }}/docker-compose.yml"
33 owner: "{{ runner_user }}"
34 group: "users"
35 mode: '0664'
36 notify: restart web-tools
37
38- name: Check if Web Tools are already running
39 community.docker.docker_compose_v2:
40 project_src: "{{ web_tools_config_dir }}"
41 state: present
42 restarted: false
43 register: web_tools_running
44 changed_when: false
45 failed_when: false
46
47- name: Start Web Tools services
48 community.docker.docker_compose_v2:
49 project_src: "{{ web_tools_config_dir }}"
50 state: present
51 register: web_tools_start_result
52 check_mode: no
53
54- name: Wait for Stirling-PDF to be healthy
55 uri:
56 url: "http://localhost:{{ web_tools_stirling_port }}/api/v1/info/status"
57 method: GET
58 status_code: 200
59 timeout: 10
60 register: stirling_health
61 until: stirling_health.status == 200
62 retries: 15
63 delay: 10
64 failed_when: false
65 when: web_tools_start_result is changed
66 check_mode: no
67
68- name: Wait for ConvertX to be healthy
69 uri:
70 url: "http://localhost:{{ web_tools_convertx_port }}/"
71 method: GET
72 status_code: [200, 302]
73 timeout: 10
74 register: convertx_health
75 until: convertx_health.status in [200, 302]
76 retries: 15
77 delay: 10
78 failed_when: false
79 when: web_tools_start_result is changed
80 check_mode: no
81
82- name: Wait for CyberChef to be healthy
83 uri:
84 url: "http://localhost:{{ web_tools_cyberchef_port }}/"
85 method: GET
86 status_code: 200
87 timeout: 10
88 register: cyberchef_health
89 until: cyberchef_health.status == 200
90 retries: 10
91 delay: 5
92 failed_when: false
93 when: web_tools_start_result is changed
94 check_mode: no
95
96- name: Wait for IT-Tools to be healthy
97 uri:
98 url: "http://localhost:{{ web_tools_it_tools_port }}/"
99 method: GET
100 status_code: 200
101 timeout: 10
102 register: it_tools_health
103 until: it_tools_health.status == 200
104 retries: 10
105 delay: 5
106 failed_when: false
107 when: web_tools_start_result is changed
108 check_mode: no
109
110- name: Display Web Tools deployment summary
111 debug:
112 msg: |
113 Web Tools Deployment:
114 - Status: {{ 'Started' if web_tools_start_result is changed else 'Already running' }}
115 - Stirling-PDF: http://{{ ansible_default_ipv4.address }}:{{ web_tools_stirling_port }} ({{ 'OK' if (stirling_health.status | default(0)) == 200 else 'Check manually' }})
116 - ConvertX: http://{{ ansible_default_ipv4.address }}:{{ web_tools_convertx_port }} ({{ 'OK' if (convertx_health.status | default(0)) in [200, 302] else 'Check manually' }})
117 - CyberChef: http://{{ ansible_default_ipv4.address }}:{{ web_tools_cyberchef_port }} ({{ 'OK' if (cyberchef_health.status | default(0)) == 200 else 'Check manually' }})
118 - IT-Tools: http://{{ ansible_default_ipv4.address }}:{{ web_tools_it_tools_port }} ({{ 'OK' if (it_tools_health.status | default(0)) == 200 else 'Check manually' }})
119 - Configuration: {{ web_tools_config_dir }}
120