Skip to content

Commit

Permalink
Update deploy scripts for systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchrisadams committed May 9, 2024
1 parent 8ad267e commit 22c2bb3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
8 changes: 8 additions & 0 deletions ansible/_set_up_process_mgmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@
tags:
- systemd
- config

- name: Reload systemd to pick up new changes
ansible.builtin.systemd:
daemon_reload: True
become: true
tags:
- systemd
- config
26 changes: 19 additions & 7 deletions ansible/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---
- name: Deploy the TGWF django admin
hosts:
# - app_servers
- app1.thegreenwebfoundation.org
- app2.thegreenwebfoundation.org
- app3.thegreenwebfoundation.org
- app4.thegreenwebfoundation.org
# - app1.thegreenwebfoundation.org
# - app2.thegreenwebfoundation.org
# - app3.thegreenwebfoundation.org
# - app4.thegreenwebfoundation.org
- app_servers
# api servers are app1, app2, and app4, mainly serving API traffic
# - api_servers
# admin server is app3, mainly serving member portal traffic
# - admin_servers

remote_user: "deploy"
become: false
Expand Down Expand Up @@ -71,10 +75,18 @@
ansible.builtin.include_tasks: "_set_up_process_mgmt.yml"
tags:
- systemd
- systemd

- name: Query state of web app service
ansible.builtin.service_facts:
tags: [systemd-check]

- name: Show state of services
ansible.builtin.debug:
var: ansible_facts.services["{{ service_gunicorn_app }}.service"]
tags: [systemd-check]

- name: Trigger restart for app with systemd
ansible.builtin.service:
ansible.builtin.systemd:
name: "{{ service_gunicorn_app }}"
state: restarted
become: true
Expand Down
11 changes: 11 additions & 0 deletions ansible/inventories/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,14 @@ all:
# precedence over the ones further 'upstream'
# vars:
# some_var: value_here
# API servers are expected to serve the API traffic, which is the bulk of load
# we don't direct admin.TGWF to them
api_servers:
hosts:
app1.thegreenwebfoundation.org:
app2.thegreenwebfoundation.org:
app4.thegreenwebfoundation.org:
# the admin server also hosts the staging servers
admin_servers:
hosts:
app3.thegreenwebfoundation.org:
2 changes: 1 addition & 1 deletion ansible/scale_processes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- systemd

- name: Update django apps using systemd
ansible.builtin.service:
ansible.builtin.systemd:
name: "{{ service_gunicorn_app }}:"
state: "{{ preferred_state }}"
become: true
Expand Down

0 comments on commit 22c2bb3

Please sign in to comment.