-
Notifications
You must be signed in to change notification settings - Fork 17
/
site.step-60-autoscaling.yml
204 lines (188 loc) · 8.07 KB
/
site.step-60-autoscaling.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
- import_playbook: site.common.group-current-hosts.yml
# Removed because it is not working. Connection error 100%. Most likely because it tries to connect to builder that already died.
- hosts: app:¤t:&immutable
gather_facts: no
roles:
- role: cs.aws-ami-facts
ami_facts_instance: "{{ aws_app_node_instance_type_forced | default(aws_app_node_instance_type, true) }}"
delegate_to: localhost
tasks:
- block:
- name: Enable Magento maintenance mode (if AMI release has DB migrations)
command: "bin/magento maintenance:enable"
when: aws_ami_app_node_needs_db_migrations | default(true)
args:
chdir: "{{ item.dir | default(magento_live_release_dir) }}"
run_once: true
become: yes
become_user: "{{ magento_user }}"
register: enable_maintenance_mode
until: enable_maintenance_mode is not failed
retries: 10
delay: 6
rescue:
- name: Print failure warning
debug:
msg: |
=================================================
= Warning! Failed to enable maintenance mode! =
=================================================
Probably the currently deployed installation is
broken - proceeding with the asg update anyway...
- hosts: localhost
connection: local
vars:
# Disable rolling updates when enabling maintenance mode to speed
# the refresh up...
autoscaling_rolling_instance_refresh_min_healthy_percent: >-
{{
aws_ami_app_node_needs_db_migrations | default(true) | ternary(
0,
aws_autoscaling_rolling_instance_refresh_min_healthy_percent
)
}}
aws_app_node_security_group_ids: >-
{{
[
aws_security_group_app_id,
aws_security_group_ssh_id
] + (
varnish_is_in_autoscaling_group | ternary(
[
aws_security_group_varnish_id
],
[]
)
)
}}
roles:
- role: cs.aws-ami-facts
ami_facts_instance: "{{ aws_app_node_instance_type_forced | default(aws_app_node_instance_type, true) }}"
delegate_to: localhost
- role: cs.aws-autoscaling
autoscaling_assign_public_ip: yes
autoscaling_loadbalancers: "{{ aws_app_asg_load_balancers }}"
autoscaling_webnodedown_hook_create: "{{ varnish_standalone }}"
autoscaling_webnodedown_hook_name: "{{ aws_app_node_webnodedown_hook_name }}"
autoscaling_asg_name: "{{ mageops_app_name }}-app"
autoscaling_asg_desired_capacity: "{{ aws_app_asg_desired_capacity }}"
autoscaling_asg_min_size: "{{ aws_app_asg_min_size }}"
autoscaling_asg_max_size: "{{ aws_app_asg_max_size }}"
autoscaling_asg_cooldown: "{{ aws_app_asg_cooldown }}"
autoscaling_instance_ami_id: "{{ aws_ami_app_node_id }}"
autoscaling_instance_type: "{{ aws_app_node_instance_type_forced | default(aws_app_node_instance_type, true) }}"
autoscaling_instance_security_groups: "{{ aws_app_node_security_group_ids }}"
autoscaling_instance_iam_role: "{{ aws_iam_role_app_node }}"
autoscaling_instance_volume_size: "{{ aws_app_node_ebs_volume_size }}"
autoscaling_instance_tags: >-
{{
aws_tags_default | combine(
aws_tags_role_app,
aws_tags_node_app,
varnish_is_in_autoscaling_group | ternary(
aws_tags_node_app_with_varnish | combine(
aws_tags_role_http_cache,
aws_tags_role_varnish_http_cache
),
{}
)
)
}}
autoscaling_instance_ami_search_tags: >-
{{
aws_tags_base | combine(
aws_tags_role_app
)
}}
autoscaling_instance_start_script: |
{{ aws_app_node_launch_script_extra }}
{% if not magento_aws_ondemand_import_instance_enable and magento_import_dispatcher_enable %}{{ magento_import_dispatcher_switch_script_path }} on{% endif %}
/usr/bin/systemctl enable supervisord
/usr/bin/systemctl start supervisord
{% if mageops_pio_worker_enable and mageops_pio_worker_dedicated_asg %}
/usr/bin/systemctl disable --now pio-worker
{% endif %}
- role: cs.aws-autoscaling
when: aws_extra_app_asg_enable or magento_aws_ondemand_import_instance_enable
autoscaling_assign_public_ip: yes
autoscaling_loadbalancers: no
autoscaling_webnodedown_hook_create: "{{ varnish_standalone }}"
autoscaling_webnodedown_hook_name: "{{ aws_app_node_webnodedown_hook_name }}"
autoscaling_asg_name: "{{ mageops_app_name }}-extra-app"
autoscaling_asg_desired_capacity: "{{ aws_extra_app_asg_desired_capacity }}"
autoscaling_asg_min_size: "{{ aws_extra_app_asg_min_size }}"
autoscaling_asg_max_size: "{{ aws_extra_app_asg_max_size }}"
autoscaling_asg_cooldown: "{{ aws_extra_app_asg_cooldown }}"
autoscaling_instance_ami_id: "{{ aws_ami_app_node_id }}"
autoscaling_instance_type: "{{ aws_extra_app_node_instance_type }}"
autoscaling_instance_security_groups: "{{ aws_app_node_security_group_ids }}"
autoscaling_instance_iam_role: "{{ aws_iam_role_app_node }}"
autoscaling_instance_volume_size: "{{ aws_extra_app_node_ebs_volume_size }}"
autoscaling_instance_tags: >-
{{
aws_tags_default | combine(
aws_tags_role_app,
aws_tags_role_extra_app,
aws_tags_node_extra_app,
varnish_is_in_autoscaling_group | ternary(
aws_tags_node_app_with_varnish | combine(
aws_tags_role_http_cache,
aws_tags_role_varnish_http_cache
),
{}
)
)
}}
autoscaling_instance_ami_search_tags: >-
{{
aws_tags_base | combine(
aws_tags_role_app
)
}}
autoscaling_instance_start_script: |
{{ aws_app_node_launch_script_extra }}
{% if magento_import_dispatcher_enable %}{{ magento_import_dispatcher_switch_script_path }} on{% endif %}
/usr/bin/systemctl enable supervisord
/usr/bin/systemctl start supervisord
{% if mageops_pio_worker_enable and mageops_pio_worker_dedicated_asg %}
/usr/bin/systemctl disable --now pio-worker
{% endif %}
- role: cs.aws-autoscaling
autoscaling_asg_enabled: "{{ mageops_pio_worker_dedicated_asg and mageops_pio_worker_enable }}"
autoscaling_assign_public_ip: yes
autoscaling_loadbalancers: no
autoscaling_asg_name: "{{ mageops_app_name }}-pio"
autoscaling_asg_desired_capacity: "{{ aws_pio_asg_desired_capacity }}"
autoscaling_asg_min_size: "{{ aws_pio_asg_min_size }}"
autoscaling_asg_max_size: "{{ aws_pio_asg_max_size }}"
autoscaling_asg_cooldown: "{{ aws_pio_asg_cooldown }}"
autoscaling_instance_ami_id: "{{ aws_ami_app_node_id }}"
autoscaling_instance_type: "{{ aws_pio_instance_type }}"
autoscaling_instance_security_groups: "{{ aws_app_node_security_group_ids }}"
autoscaling_instance_iam_role: "{{ aws_iam_role_app_node }}"
autoscaling_instance_volume_size: "{{ aws_pio_ebs_volume_size }}"
autoscaling_instance_tags: >-
{{
aws_tags_default | combine(
aws_tags_pio_only,
aws_tags_node_pio,
)
}}
autoscaling_instance_ami_search_tags: >-
{{
aws_tags_base | combine(
aws_tags_role_app
)
}}
autoscaling_instance_start_script: |
/usr/bin/systemctl disable --now php-fpm
/usr/bin/systemctl disable --now nginx
{% if mageops_monitoring_enabled %}
/usr/bin/systemctl disable --now php-fpm-exporter
{% endif %}
{% if blackfire_install %}
/usr/bin/systemctl disable --now blackfire-agent
{% endif %}
{% if tideways_enable %}
/usr/bin/systemctl disable --now tideways-daemon
{% endif %}