-
Notifications
You must be signed in to change notification settings - Fork 17
/
site.maintenance.aws-start.yml
86 lines (76 loc) · 2.82 KB
/
site.maintenance.aws-start.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
- hosts: localhost
connection: local
roles:
- role: cs.aws-region-facts
- role: cs.aws-rds-facts
- role: cs.aws-node-facts
- role: cs.aws-autoscaling-facts
tasks:
- name: Start standalone EC2 instances
when: start_ec2
amazon.aws.ec2_instance:
instance_ids: "{{ item.instance_id }}"
region: "{{ aws_region }}"
state: running
wait: yes
with_items:
- "{{ aws_persistent_node_instance }}"
- "{{ aws_varnish_node_instance }}"
- name: Wait 300 seconds for port 22 to become open and contain "OpenSSH"
ansible.builtin.wait_for:
port: 22
host: '{{ aws_varnish_node_elastic_ip }}'
search_regex: OpenSSH
delay: 10
connection: local
- name: Scale up App Node ASGs
when: start_asg
block:
- name: Get Auto Scaling Groups for App
community.aws.ec2_asg_info:
region: "{{ aws_region }}"
tags: "{{ aws_tags_base | combine(aws_tags_node_app) }}"
register: start_asg_facts
- name: Scale up ASG
ec2_asg:
name: "{{ item.name }}"
region: "{{ aws_region }}"
state: present
desired_capacity: "{{ aws_app_asg_desired_capacity | default(1) }}"
min_size: "{{ aws_app_asg_min_size | default(1) }}"
wait_for_instances: yes
wait_timeout: 600
with_items: "{{ start_asgs }}"
vars:
start_asgs: "{{ start_asg_facts | json_query('results[].{ name: auto_scaling_group_name } ') }}"
- name: Scale up Extra App Node ASGs
when: start_asg and (aws_extra_app_asg_enable or magento_aws_ondemand_import_instance_enable)
block:
- name: Get Auto Scaling Groups for Extra App
community.aws.ec2_asg_info:
region: "{{ aws_region }}"
tags: "{{ aws_tags_base | combine(aws_tags_node_extra_app) }}"
register: start_asg_facts
- name: Scale up ASG
ec2_asg:
name: "{{ item.name }}"
region: "{{ aws_region }}"
state: present
desired_capacity: "{{ aws_extra_app_asg_desired_capacity | default(0) }}"
min_size: "{{ aws_extra_app_asg_min_size | default(0) }}"
wait_for_instances: yes
wait_timeout: 600
with_items: "{{ start_asgs }}"
vars:
start_asgs: "{{ start_asg_facts | json_query('results[].{ name: auto_scaling_group_name } ') }}"
- name: Start RDS instance
rds_instance:
state: started
region: "{{ aws_region }}"
db_instance_identifier: "{{ aws_rds_instance.db_instance_identifier }}"
when: start_rds and aws_rds_instance is defined
vars:
start: yes
start_ec2: "{{ start }}"
start_asg: "{{ start }}"
start_rds: "{{ start }}"