Skip to content

Commit

Permalink
fix cleanup AMI Snapshots. Bug fixed ansible/ansible#39541
Browse files Browse the repository at this point in the history
  • Loading branch information
reelsense committed May 29, 2020
1 parent aaf2f75 commit 7bfac95
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions cleanup_ami_snapshots/cleanup-ami-snapshots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
when: not aws_region_env_var

- name: Gather facts about all AMIs with given tag.
ec2_ami_facts:
ec2_ami_info:
profile: "{{ aws_profile }}"
owners: self
filters: "{{ ami_tag }}"
Expand Down Expand Up @@ -59,8 +59,7 @@
profile: "{{ aws_profile }}"
image_id: "{{ oldest_ami.image_id }}"
state: absent
# Bug in deleting snapshots : https://github.com/ansible/ansible/issues/39541
#delete_snapshot: yes
delete_snapshot: yes
when: ami_list.images

- name: LOG action
Expand All @@ -69,14 +68,6 @@
dest: "{{ log_destination }}"
when: ami_list.images

- name: Cleanup AMI snapshots
ec2_snapshot:
profile: "{{ aws_profile }}"
snapshot_id: "{{ item.ebs.snapshot_id }}"
state: absent
with_items: "{{ oldest_ami.block_device_mappings }}"
when: ami_list.images

- name: LOG action
lineinfile:
line: "{{ ansible_date_time.iso8601 }} AMI CLEANUP - Removed snapshots: {{ item.ebs.snapshot_id }}"
Expand Down

0 comments on commit 7bfac95

Please sign in to comment.