Clean up AMI and related snapshots #2
Labels
No labels
bug
duplicate
enhancement
good first issue
help wanted
invalid
question
todo
todo 🗒️
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: stationgroup/ansible-experiments#2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I need an Ansible Role/Playbook that can remove old AMI's and the related snapshots that were created using this
ec2_ami_module
with machines taggedMakeImage
=true
. I will probably execute this playbook from a scheduled cron job.MakeImage
=true
DestroyImage
=true
.ℹ️ Maybe this method I'm imagining above isn't the correct method. Maybe it would be safer to create a Playbook that adds something like a
DestroyImage
=true
tag. Then an additional removal Role that only removes things that are taggedDestroyImage
=true
. I think this sounds safer as I write this...Need quote and your input on this also.
x-post: https://github.com/stationgroup/ansible-experiments/pull/8
I clearly recalled having commented on this issue, and now it seems that is lost, or was not posted.
Most important part of this, is I need a way to test scripts with real AWS AMI info of your infrastructure. Do you see a way how this can happen? At least I'd need an example of return data of the ec2_ami_module
I’ll setup a testing account that you can start up instances on.
--
PGP:5EC1494DC59141C0
I emailed the credentials for this experiment and setup a server in the Frankfurt region for you with the correct tags.
If you email a public key I can add you to the
authorized_keys
file or you can create an EC2 instance and AMI with the System Administrator IAM policy your account has. This way I can pay for any EC2 expenses incurred during this.Do you have specific AMI's you manage, and a procedure or script when you make snapshots? Or is there a way to quickly simulate having "old" AMI's and snapshots that should be deleted?
I'll reply out of band regarding that question.
There seems to be a very particular issue that I only hit in production.
I've reproduced it using the test AMI playbook that you made and made a screen recording.
VIDEO LINK
https://www.youtube.com/watch?v=V-1W1o4otrI
Can you add what is needed so that I don't error out under the conditions in the video. It seems like a
true
value followed by an empty value causes it.Can you confirm me the exact ansible version you use? (just to be sure)
The above is in production.
This is the version in the video:
If solving this issue is more trouble than it's worth, let me know.
It's a real scenario; But maybe it's easier for the playbook to print a message that there is a
DestroyImage
key with an empty value and fail. And then I would just manually go through and find the missing value and remove the key.Hi, I'm helping @srgvg on this. Could you provide the following information:
sudo pip show boto
sudo pip show boto3
aws --version
sudo pip show boto
sudo pip show boto3
aws --version
Could you update these and try to reproduce?
sudo pip install --upgrade botocore
sudo pip install --upgrade boto3
sudo pip install --upgrade boto
Nothing changed from what I showed in the video.
sudo pip show boto
sudo pip show boto3
aws --version
Somehow I cannot reproduce this.
video capture: https://youtu.be/Fxm0RSXRLrY
Strange... You copied my method exactly in the video. I can reproduce it on 2 separate AWS accounts, on 2 different OS's, in 2 different regions. One with IAM Roles for permissions, and one with IAM access keys (Administrator Access).
Thank you for your help. I'll close this and email @srgvg now.
U-496024757E7019832