forked from openaustralia/infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-ssl-certs.yml
69 lines (57 loc) · 1.69 KB
/
update-ssl-certs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Run this like so:
# ansible-playbook -i ec2-hosts update-ssl-certs.yml
# To only run this for planningalerts:
# ansible-playbook -i ec2-hosts update-ssl-certs.yml -l planningalerts
# To only run this for openaustralia:
# ansible-playbook -i ec2-hosts update-ssl-certs.yml -l openaustralia
- hosts: ec2
become: true
tasks:
- name: Check if Apache is running
command: systemctl status apache2
ignore_errors: yes
changed_when: false
register: service_apache_status
- name: Check if Nginx is running
command: systemctl status nginx
ignore_errors: yes
changed_when: false
register: service_nginx_status
- name: Check if Varnish is running
command: systemctl status varnish
ignore_errors: yes
changed_when: false
register: service_varnish_status
- name: Pause apache2
service:
name: apache2
state: stopped
when: service_apache_status is success
- name: Pause nginx
service:
name: nginx
state: stopped
when: service_nginx_status is success
- name: Pause varnish
service:
name: varnish
state: stopped
when: service_varnish_status is success
- name: Attempt cert renewal
shell: letsencrypt renew --no-self-upgrade
ignore_errors: yes
- name: Restart varnish
service:
name: varnish
state: started
when: service_varnish_status is success
- name: Restart apache2
service:
name: apache2
state: started
when: service_apache_status is success
- name: Restart nginx
service:
name: nginx
state: started
when: service_nginx_status is success