-
Notifications
You must be signed in to change notification settings - Fork 17
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
Dev find untagged #332
base: develop
Are you sure you want to change the base?
Dev find untagged #332
Conversation
2e5b599
to
baafee3
Compare
site.maintenance.find-untagged.yml
Outdated
- hosts: localhost | ||
connection: local | ||
vars: | ||
_ec2_whitelist: |
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.
whitelist cannot be global in repo
it needs to be set per project
as this script will be executed on every project and because this is public repository also outside company
filters: | ||
"tag:Infrastructure": 'mageops' | ||
"tag:Tool": 'ansible' | ||
instance-state-name: "{{ _ec2_filters }}" |
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.
there is much more states than "running" and "stopped", ideally we would want to catch all of them
I would change it to not filter it here, instead later one ignore all that are in "terminated" state
site.maintenance.find-untagged.yml
Outdated
- name: Generate list EC2 to review | ||
set_fact: | ||
_ec2_untagged_list: "{{ _ec2_untagged_list + [{ 'id' : item.instance_id, 'name' : item.tags.Name }] }}" | ||
when: item.instance_id not in _ec2_whitelist |
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.
this way we need to fetch instances twice to compare them
Better way would be to only list all instances
and then filter out instances that have correct tags/ids
- name: Find unused EBS volumes | ||
ec2_vol_info: | ||
filters: | ||
status: "available" |
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.
this is clever way to extract it 👍
site.maintenance.find-untagged.yml
Outdated
|
||
- name: Set _ec2_list_review | ||
set_fact: | ||
_ec2_list_review: "{{ _ec2_list_review | default() + 'ID : ' + item.id + ' Name : ' + item.name + '\n' }}" |
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.
does that syntax even works?
not sure what is going on here
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.
Changed to more readable
320ac9c
to
bde9326
Compare
… volumes. This scipt failed when found some resources without proper tags or EBS in state availabe (unassigned) Signed-off-by: Mariusz Jóźwiak <[email protected]>
bde9326
to
e229618
Compare
To reduce cost script to find EC2 without MegaOps tags and unused EBS volumes. This scipt failed when found some resources without proper tags or EBS in state availabe (unassigned)