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.
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.
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.
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.
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.
does that syntax even works?
not sure what is going on here
There was a problem hiding this comment.
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)