-
Notifications
You must be signed in to change notification settings - Fork 1
/
instance_change.yml
41 lines (41 loc) · 1.09 KB
/
instance_change.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
---
- hosts: all
remote_user: jonyc
gather_facts: no
vars:
region: us-west-1
instance_type: r4.2xlarge
profile: production_96
tasks:
# - name: get instance id
# uri:
# url: http://169.254.169.254/latest/meta-data/instance-id
# return_content: yes
# register: instance_id
- name: get instance id
shell: curl -sG http://169.254.169.254/latest/meta-data/instance-id
register: instance_id
- name: stop instance
ec2:
instance_ids: '{{ instid }}'
region: '{{ region }}'
state: stopped
profile: '{{ profile }}'
wait: True
delegate_to: 127.0.0.1
- name: change the type
ec2_type:
region: '{{ region }}'
profile: '{{ profile}}'
id: '{{ instid }}'
type: '{{ totype }}'
delegate_to: 127.0.0.1
- name: Start the sandbox instances
ec2:
instance_ids: '{{ instid }}'
region: '{{ region }}'
profile: '{{ profile }}'
state: running
wait: True
instance_type: '{{ totype }}'
delegate_to: 127.0.0.1