-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add uptime parameter for ec2_instance_info module in minutes #356
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
minor_changes: | ||
- adding minimum_uptime and alias uptime to filter instances that have only been online for certain duration of time in minutes | ||
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" | ||
tremble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.