-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprod_deploy.yml
96 lines (84 loc) · 2.38 KB
/
prod_deploy.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
- name: Setup EC2
hosts: all
become: yes
tasks:
- name: Create the /etc/ecs directory
file:
path: /etc/ecs
state: directory
mode: '0755'
- name: Configure ECS Cluster
copy:
content: "ECS_CLUSTER=techronomicon-cluster"
dest: /etc/ecs/ecs.config
owner: root
group: root
mode: '0644'
- name: Install ecs-init, nginx, and python3-pip
dnf:
name:
- ecs-init
- nginx
- amazon-cloudwatch-agent
- collectd
state: present
update_cache: yes
- name: Enable and start ecs.service
systemd:
name: ecs.service
enabled: yes
state: started
daemon_reload: yes
no_block: yes
- name: Install certbot and certbot-nginx via pip
pip:
name:
- certbot
- certbot-nginx
state: present
- name: Deploy Nginx preprod configuration
copy:
src: ./files/prod/lukecollins.dev.conf
dest: /etc/nginx/conf.d/lukecollins.dev.conf
owner: root
group: root
mode: '0644'
register: nginx_config_changed
- name: Restart Nginx service
systemd:
name: nginx
state: restarted
enabled: yes
when: nginx_config_changed.changed
- name: Check if certificate exists
stat:
path: /etc/letsencrypt/live/lukecollins.dev/fullchain.pem
register: cert_exists
- name: Obtain and install SSL certificates for multiple domains
command: >
certbot --nginx
--non-interactive
--agree-tos
--email [email protected]
-d lukecollins.dev
when: not cert_exists.stat.exists
become: yes
- name: Copy CloudWatch Agent configuration
copy:
src: ./files/common/cloudwatch-agent-config.json
dest: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
owner: root
group: root
mode: '0644'
register: cloudwatch_agent_config_changed
- name: Enable amazon-cloudwatch-agent service
systemd:
name: amazon-cloudwatch-agent
enabled: yes
when: cloudwatch_agent_config_changed.changed
- name: Start amazon-cloudwatch-agent service
systemd:
name: amazon-cloudwatch-agent
state: started
when: cloudwatch_agent_config_changed.changed