Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from hexadecimalDinosaur/fix_nginx_ansible
Browse files Browse the repository at this point in the history
Fix ansible job for nginx deployment and first time run
  • Loading branch information
hexadecimalDinosaur authored Oct 22, 2023
2 parents e9670b4 + efca39c commit 583e42a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
22 changes: 14 additions & 8 deletions ansible/nginx.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
---

- name: Nginx playbook
hosts: webserver
become: true
gather_facts: no
pre_tasks:
- name: Load variables
ansible.builtin.include_vars:
file: vars.yml
- name: Connection Wait
ansible.builtin.wait_for_connection:
timeout: 300
tasks:
- name: Install nginx
ansible.builtin.package:
name: nginx
state: present
notify: Reload nginx
notify: Restart nginx
- name: Copy nginx config
ansible.builtin.copy:
src: nginx.conf
dest: "/etc/nginx/sites-enabled/{{ project_name }}"
mode: '644'
notify: Reload nginx config
- name: Unlink default nginx
ansible.builtin.command:
cmd: unlink /etc/nginx/sites-enabled/default
removes: /etc/nginx/sites-enabled/default
notify: Reload nginx config
notify: Restart nginx
- name: Import Python tasks
ansible.builtin.include_tasks:
file: tasks/python.yml
when: project_language == 'python'
- name: Restart nginx server
ansible.builtin.service:
name: nginx
state: restarted
enabled: true
handlers:
- name: Reload nginx
- name: Restart nginx
ansible.builtin.service:
name: nginx
state: reloaded
state: restarted
enabled: true
- name: Reload nginx config
ansible.builtin.command:
cmd: nginx -s reload
- name: Reload supervisor
ansible.builtin.service:
name: supervisor
Expand Down
22 changes: 14 additions & 8 deletions deploy_bundle/nginx.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
---

- name: Nginx playbook
hosts: webserver
become: true
gather_facts: no
pre_tasks:
- name: Load variables
ansible.builtin.include_vars:
file: vars.yml
- name: Connection Wait
ansible.builtin.wait_for_connection:
timeout: 300
tasks:
- name: Install nginx
ansible.builtin.package:
name: nginx
state: present
notify: Reload nginx
notify: Restart nginx
- name: Copy nginx config
ansible.builtin.copy:
src: nginx.conf
dest: "/etc/nginx/sites-enabled/{{ project_name }}"
mode: '644'
notify: Reload nginx config
- name: Unlink default nginx
ansible.builtin.command:
cmd: unlink /etc/nginx/sites-enabled/default
removes: /etc/nginx/sites-enabled/default
notify: Reload nginx config
notify: Restart nginx
- name: Import Python tasks
ansible.builtin.include_tasks:
file: tasks/python.yml
when: project_language == 'python'
- name: Restart nginx server
ansible.builtin.service:
name: nginx
state: restarted
enabled: true
handlers:
- name: Reload nginx
- name: Restart nginx
ansible.builtin.service:
name: nginx
state: reloaded
state: restarted
enabled: true
- name: Reload nginx config
ansible.builtin.command:
cmd: nginx -s reload
- name: Reload supervisor
ansible.builtin.service:
name: supervisor
Expand Down

0 comments on commit 583e42a

Please sign in to comment.