This commit is contained in:
Bryan Black 2020-05-28 18:09:08 -07:00 committed by GitHub
parent aaf2f75d66
commit 7bfac9599d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,7 +22,7 @@
when: not aws_region_env_var when: not aws_region_env_var
- name: Gather facts about all AMIs with given tag. - name: Gather facts about all AMIs with given tag.
ec2_ami_facts: ec2_ami_info:
profile: "{{ aws_profile }}" profile: "{{ aws_profile }}"
owners: self owners: self
filters: "{{ ami_tag }}" filters: "{{ ami_tag }}"
@ -59,8 +59,7 @@
profile: "{{ aws_profile }}" profile: "{{ aws_profile }}"
image_id: "{{ oldest_ami.image_id }}" image_id: "{{ oldest_ami.image_id }}"
state: absent state: absent
# Bug in deleting snapshots : https://github.com/ansible/ansible/issues/39541 delete_snapshot: yes
#delete_snapshot: yes
when: ami_list.images when: ami_list.images
- name: LOG action - name: LOG action
@ -69,14 +68,6 @@
dest: "{{ log_destination }}" dest: "{{ log_destination }}"
when: ami_list.images 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 - name: LOG action
lineinfile: lineinfile:
line: "{{ ansible_date_time.iso8601 }} AMI CLEANUP - Removed snapshots: {{ item.ebs.snapshot_id }}" line: "{{ ansible_date_time.iso8601 }} AMI CLEANUP - Removed snapshots: {{ item.ebs.snapshot_id }}"