forked from ansible-collections/amazon.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add uptime parameter for ec2_instance_info module in minutes (ansible…
…-collections#356) * syncing module and tests for uptime with tons of help from Yanis, we now have uptime in there * updating pr with fixes from suggestions adding to ansible-collections/community.aws#356 with comments from @tremble and @duderamos * Create 356_add_minimum_uptime_parameter.yaml adding changelog fragment per @gravesm suggestion * Update 356_add_minimum_uptime_parameter.yaml last comment from @tremble Co-authored-by: Sean Cavanaugh <[email protected]>
- Loading branch information
Showing
2 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
tests/integration/targets/ec2_instance/roles/ec2_instance/tasks/uptime.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
- block: | ||
- name: "create t3.nano instance" | ||
ec2_instance: | ||
name: "{{ resource_prefix }}-test-uptime" | ||
region: "{{ ec2_region }}" | ||
image_id: "{{ ec2_ami_image }}" | ||
tags: | ||
TestId: "{{ ec2_instance_tag_TestId }}" | ||
vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" | ||
instance_type: t3.nano | ||
wait: yes | ||
|
||
- name: "check ec2 instance" | ||
ec2_instance_info: | ||
filters: | ||
"tag:Name": "{{ resource_prefix }}-test-uptime" | ||
instance-state-name: [ "running"] | ||
register: instance_facts | ||
|
||
- name: "Confirm existence of instance id." | ||
assert: | ||
that: | ||
- "{{ instance_facts.instances | length }} == 1" | ||
|
||
- name: "check using uptime 100 hours - should find nothing" | ||
ec2_instance_info: | ||
region: "{{ ec2_region }}" | ||
uptime: 6000 | ||
filters: | ||
instance-state-name: [ "running"] | ||
"tag:Name": "{{ resource_prefix }}-test-uptime" | ||
register: instance_facts | ||
|
||
- name: "Confirm there is no running instance" | ||
assert: | ||
that: | ||
- "{{ instance_facts.instances | length }} == 0" | ||
|
||
- name: Sleep for 61 seconds and continue with play | ||
wait_for: | ||
timeout: 61 | ||
delegate_to: localhost | ||
|
||
- name: "check using uptime 1 minute" | ||
ec2_instance_info: | ||
region: "{{ ec2_region }}" | ||
uptime: 1 | ||
filters: | ||
instance-state-name: [ "running"] | ||
"tag:Name": "{{ resource_prefix }}-test-uptime" | ||
register: instance_facts | ||
|
||
- name: "Confirm there is one running instance" | ||
assert: | ||
that: | ||
- "{{ instance_facts.instances | length }} == 1" | ||
|
||
always: | ||
- name: "Terminate instances" | ||
ec2_instance: | ||
state: absent | ||
filters: | ||
"tag:TestId": "{{ ec2_instance_tag_TestId }}" | ||
wait: yes | ||
ignore_errors: yes |