· last year · Nov 30, 2023, 04:15 PM
1# START - PLAYBOOK
2---
3# change ec2 instance type
4- name: Change EC2 instance type
5 hosts: "{{ hosts_used }}"
6 gather_facts: false
7 vars_files:
8 - /opt/ansible/vars/generated-vars.yml
9 tasks:
10 - name: Change EC2 instance type
11 delegate_to: localhost
12 environment:
13 AWS_PROFILE: "{{ aws_profile_used }}"
14 amazon.aws.ec2_instance:
15 instance_ids: "{{ instance_id }}"
16 region: "{{ region }}"
17 instance_type: t4g.large
18# END - PLAYBOOK
19
20# START - RESULTS - Normal Run
21ansible-playbook files-temp/change-ec2-type.yml -e '{"hosts_used":"SERVERNAME"}'
22
23PLAY [Change EC2 instance type] *********************************************************************************************************************
24
25TASK [Change EC2 instance type] *********************************************************************************************************************
26ok: [SERVERNAME -> localhost]
27
28PLAY RECAP ******************************************************************************************************************************************
29SERVERNAME : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
30# END - RESULTS - Normal Run
31
32# START - RESULTS - `-vvv` Run
33ansible-playbook files-temp/change-ec2-type.yml -e '{"hosts_used":"SERVERNAME"}' -vvv
34ansible-playbook [core 2.15.5]
35 config file = /opt/ansible/ansible.cfg
36 configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
37 ansible python module location = /home/ec2-user/.local/lib/python3.9/site-packages/ansible
38 ansible collection location = /opt/ansible/ansible_collections
39 executable location = /home/ec2-user/.local/bin/ansible-playbook
40 python version = 3.9.16 (main, May 31 2023, 12:21:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3)
41 jinja version = 3.0.2
42 libyaml = True
43Using /opt/ansible/ansible.cfg as config file
44host_list declined parsing /opt/ansible/inventory/dynamic/devops.aws_ec2.yaml as it did not pass its verify_file() method
45Using inventory plugin 'ansible_collections.amazon.aws.plugins.inventory.aws_ec2' to process inventory source '/opt/ansible/inventory/dynamic/devops.aws_ec2.yaml'
46Parsed /opt/ansible/inventory/dynamic/devops.aws_ec2.yaml inventory source with auto plugin
47host_list declined parsing /opt/ansible/inventory/dynamic/gov.aws_ec2.yaml as it did not pass its verify_file() method
48Using inventory plugin 'ansible_collections.amazon.aws.plugins.inventory.aws_ec2' to process inventory source '/opt/ansible/inventory/dynamic/gov.aws_ec2.yaml'
49Parsed /opt/ansible/inventory/dynamic/gov.aws_ec2.yaml inventory source with auto plugin
50host_list declined parsing /opt/ansible/inventory/dynamic/prod.aws_ec2.yaml as it did not pass its verify_file() method
51Using inventory plugin 'ansible_collections.amazon.aws.plugins.inventory.aws_ec2' to process inventory source '/opt/ansible/inventory/dynamic/prod.aws_ec2.yaml'
52Parsed /opt/ansible/inventory/dynamic/prod.aws_ec2.yaml inventory source with auto plugin
53redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
54redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
55Skipping callback 'default', as we already have a stdout callback.
56Skipping callback 'minimal', as we already have a stdout callback.
57Skipping callback 'oneline', as we already have a stdout callback.
58
59PLAYBOOK: change-ec2-type.yml ***********************************************************************************************************************
601 plays in files-temp/change-ec2-type.yml
61Read vars_file '/opt/ansible/vars/generated-vars.yml'
62Read vars_file '/opt/ansible/vars/generated-vars.yml'
63Read vars_file '/opt/ansible/vars/generated-vars.yml'
64
65PLAY [Change EC2 instance type] *********************************************************************************************************************
66Read vars_file '/opt/ansible/vars/generated-vars.yml'
67Read vars_file '/opt/ansible/vars/generated-vars.yml'
68Read vars_file '/opt/ansible/vars/generated-vars.yml'
69
70TASK [Change EC2 instance type] *********************************************************************************************************************
71task path: /opt/ansible/files-temp/change-ec2-type.yml:9
72Read vars_file '/opt/ansible/vars/generated-vars.yml'
73<localhost> ESTABLISH LOCAL CONNECTION FOR USER: ec2-user
74<localhost> EXEC /bin/sh -c 'echo ~ec2-user && sleep 0'
75<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ec2-user/.ansible/tmp `"&& mkdir "` echo /home/ec2-user/.ansible/tmp/ansible-tmp-1701359858.3848865-3955368-160910192259622 `" && echo ansible-tmp-1701359858.3848865-3955368-160910192259622="` echo /home/ec2-user/.ansible/tmp/ansible-tmp-1701359858.3848865-3955368-160910192259622 `" ) && sleep 0'
76Using module file /opt/ansible/ansible_collections/amazon/aws/plugins/modules/ec2_instance.py
77<localhost> PUT /home/ec2-user/.ansible/tmp/ansible-local-395533845fq6x50/tmpsuc8y81m TO /home/ec2-user/.ansible/tmp/ansible-tmp-1701359858.3848865-3955368-160910192259622/AnsiballZ_ec2_instance.py
78<localhost> EXEC /bin/sh -c 'chmod u+x /home/ec2-user/.ansible/tmp/ansible-tmp-1701359858.3848865-3955368-160910192259622/ /home/ec2-user/.ansible/tmp/ansible-tmp-1701359858.3848865-3955368-160910192259622/AnsiballZ_ec2_instance.py && sleep 0'
79<localhost> EXEC /bin/sh -c 'AWS_PROFILE=ansible-devops /usr/bin/python3 /home/ec2-user/.ansible/tmp/ansible-tmp-1701359858.3848865-3955368-160910192259622/AnsiballZ_ec2_instance.py && sleep 0'
80<localhost> EXEC /bin/sh -c 'rm -f -r /home/ec2-user/.ansible/tmp/ansible-tmp-1701359858.3848865-3955368-160910192259622/ > /dev/null 2>&1 && sleep 0'
81ok: [SERVERNAME -> localhost] => changed=false
82 changes: []
83 instance_ids:
84 - i-INSTANCE-ID
85 instances:
86 - ami_launch_index: 0
87 architecture: x86_64
88 block_device_mappings:
89 - device_name: /dev/xvda
90 ebs:
91 attach_time: '2022-12-02T17:02:57+00:00'
92 delete_on_termination: true
93 status: attached
94 volume_id: vol-VOLUME
95 capacity_reservation_specification:
96 capacity_reservation_preference: open
97 client_token: xxTOKENxx
98 cpu_options:
99 core_count: 1
100 threads_per_core: 2
101 current_instance_boot_mode: legacy-bios
102 ebs_optimized: false
103 ena_support: true
104 enclave_options:
105 enabled: false
106 hibernation_options:
107 configured: false
108 hypervisor: xen
109 iam_instance_profile:
110 arn: arn:aws:iam::xxIAM-PROFILExx
111 id: xxIDxx
112 image_id: ami-xxAMIxx
113 instance_id: i-INSTANCE-ID
114 instance_type: t3a.large
115 key_name: useast-001
116 launch_time: '2023-11-29T14:09:46+00:00'
117 maintenance_options:
118 auto_recovery: default
119 metadata_options:
120 http_endpoint: enabled
121 http_protocol_ipv6: disabled
122 http_put_response_hop_limit: 1
123 http_tokens: optional
124 instance_metadata_tags: disabled
125 state: applied
126 monitoring:
127 state: enabled
128 network_interfaces:
129 - attachment:
130 attach_time: '2022-12-02T17:02:57+00:00'
131 attachment_id: eni-attach-xxATTACH-IDxx
132 delete_on_termination: true
133 device_index: 0
134 network_card_index: 0
135 status: attached
136 description: ''
137 groups:
138
139 interface_type: interface
140 ipv6_addresses: []
141 mac_address: 02:51:78:b6:2e:fb
142 network_interface_id: eni-06b32375a769ce152
143 owner_id: 'xxOWNERxx'
144 private_dns_name: xxIPxx.ec2.internal
145 private_ip_address: xxIPxx
146 private_ip_addresses:
147 - primary: true
148 private_dns_name: xxIPxx.ec2.internal
149 private_ip_address: xxIPxx
150 source_dest_check: true
151 status: in-use
152 subnet_id: subnet-xxSUBNETxx
153 vpc_id: vpc-xxVPCxx
154 placement:
155 availability_zone: us-east-1b
156 group_name: ''
157 tenancy: default
158 platform_details: Linux/UNIX
159 private_dns_name: xxIPxx.ec2.internal
160 private_dns_name_options:
161 enable_resource_name_dns_a_record: false
162 enable_resource_name_dns_aaaa_record: false
163 hostname_type: ip-name
164 private_ip_address: xxIPxx
165 product_codes: []
166 public_dns_name: ''
167 root_device_name: /dev/xvda
168 root_device_type: ebs
169 security_groups:
170
171 source_dest_check: true
172 state:
173 code: 80
174 name: stopped
175 state_reason:
176 code: Client.UserInitiatedShutdown
177 message: 'Client.UserInitiatedShutdown: User initiated shutdown'
178 state_transition_reason: User initiated (2023-11-30 02:13:02 GMT)
179 subnet_id: subnet-xxSUBNETxx
180 tags:
181
182 usage_operation: RunInstances
183 usage_operation_update_time: '2022-12-02T17:02:57+00:00'
184 virtualization_type: hvm
185 vpc_id: vpc-xxVPCxx
186 invocation:
187 module_args:
188 aap_callback: null
189 access_key: null
190 availability_zone: null
191 aws_ca_bundle: null
192 aws_config: null
193 count: null
194 cpu_credit_specification: null
195 cpu_options: null
196 debug_botocore_endpoint_logs: false
197 detailed_monitoring: null
198 ebs_optimized: null
199 endpoint_url: null
200 exact_count: null
201 filters: null
202 hibernation_options: false
203 iam_instance_profile: null
204 image: null
205 image_id: null
206 instance_ids:
207 - i-INSTANCE-ID
208 instance_initiated_shutdown_behavior: null
209 instance_type: t4g.large
210 key_name: null
211 launch_template: null
212 metadata_options: null
213 name: null
214 network: null
215 placement_group: null
216 profile: ansible-devops
217 purge_tags: true
218 region: us-east-1
219 secret_key: null
220 security_group: null
221 security_groups: []
222 session_token: null
223 state: present
224 tags: null
225 tenancy: null
226 termination_protection: null
227 user_data: null
228 validate_certs: true
229 volumes: null
230 vpc_subnet_id: null
231 wait: true
232 wait_timeout: 600
233Read vars_file '/opt/ansible/vars/generated-vars.yml'
234Read vars_file '/opt/ansible/vars/generated-vars.yml'
235Read vars_file '/opt/ansible/vars/generated-vars.yml'
236Read vars_file '/opt/ansible/vars/generated-vars.yml'
237
238PLAY RECAP ******************************************************************************************************************************************
239SERVERNAME : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
240# END - RESULTS - `-vvv` Run