File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
Expand file tree Collapse file tree 2 files changed +60
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Update Git Repository (Parallel)
3+ hosts : ' {{ variable_host | default("null") }}'
4+ become : true
5+ serial : " {{ ansible_play_batch | length }}"
6+
7+ tasks :
8+ - name : Update Git Repository
9+ git :
10+ repo : https://github.com/freeCodeCamp/nginx-config.git
11+ dest : /etc/nginx
12+ clone : false
13+ update : true
14+ force : true
15+ single_branch : true
16+ version : main
17+ accept_hostkey : true
18+ register : git_update
19+
20+ - name : Check if Git Repository was Updated
21+ debug :
22+ msg :
23+ ' Git Repository was updated, you should run the pipeline for a new
24+ deployment.'
25+ when : git_update.changed
26+
27+ - name : Check NGINX Config
28+ shell :
29+ chdir : /etc/nginx
30+ cmd : nginx -t
31+ register : nginx_config_check
32+ ignore_errors : true
33+
34+ - name : Notify if NGINX Config Check Failed
35+ debug :
36+ msg : " NGINX configuration check failed! Please review the configuration before proceeding."
37+ when : nginx_config_check.rc != 0
38+
39+ - name : Reload NGINX (Staggered)
40+ hosts : ' {{ variable_host | default("null") }}'
41+ become : true
42+ serial : 1
43+
44+ tasks :
45+ - name : Add a delay to stagger the reloads
46+ pause :
47+ seconds : " {{ range(5, 30) | random(seed=inventory_hostname) }}"
48+
49+ - name : Start NGINX
50+ service :
51+ name : nginx
52+ state : started
53+ enabled : true
54+ when : hostvars[inventory_hostname]['nginx_config_check'] is defined and hostvars[inventory_hostname]['nginx_config_check'].rc == 0
55+
56+ - name : Reload NGINX
57+ shell :
58+ chdir : /etc/nginx
59+ cmd : nginx -s 'reload'
60+ when : hostvars[inventory_hostname]['nginx_config_check'] is defined and hostvars[inventory_hostname]['nginx_config_check'].rc == 0
You can’t perform that action at this time.
0 commit comments