diff --git a/ansible/play-any--update-client-config.yml b/ansible/play-oldeworld--update-client-config.yml similarity index 100% rename from ansible/play-any--update-client-config.yml rename to ansible/play-oldeworld--update-client-config.yml diff --git a/ansible/play-oldeworld--update-nginx-config.yml b/ansible/play-oldeworld--update-nginx-config.yml new file mode 100644 index 000000000..a555ef812 --- /dev/null +++ b/ansible/play-oldeworld--update-nginx-config.yml @@ -0,0 +1,54 @@ +--- +- name: Update NGINX Config and reload server + hosts: '{{ variable_host | default("null") }}' + become: true + serial: 1 + + tasks: + - name: Add a delay to stagger the reloads + pause: + seconds: "{{ 10 + (ansible_play_batch.index | random(seed=inventory_hostname)) }}" + + - name: Update Git Repository + git: + repo: https://github.com/freeCodeCamp/nginx-config.git + dest: /etc/nginx + clone: false + update: true + force: true + single_branch: true + version: master + accept_hostkey: true + register: git_update + + - name: Check if Git Repository was Updated + debug: + msg: + 'Git Repository was updated, you should run the pipeline for a new + deployment.' + when: git_update.changed + + - name: Check NGINX Config + shell: + chdir: /etc/nginx + cmd: nginx -t + register: nginx_config_check + ignore_errors: true + + - name: Notify if NGINX Config Check Failed + debug: + msg: "NGINX configuration check failed! Please review the configuration before proceeding." + when: nginx_config_check.rc != 0 + + - name: Start NGINX + service: + name: nginx + state: started + enabled: true + when: nginx_config_check.rc == 0 + + - name: Reload NGINX + shell: + chdir: /etc/nginx + cmd: nginx -s 'reload' + when: nginx_config_check.rc == 0