Skip to content

Commit bde9326

Browse files
fix desc
1 parent 15f55c3 commit bde9326

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

site.maintenance.find-untagged.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
- "pending"
88
- "shutting-down"
99
- "stopping"
10-
_ec2_ebs_list_review: []
10+
_ec2_ebs_list_to_review: []
1111
_ec2_untagged_list: []
12+
_ec2_list_to_review :
1213
roles:
1314
- role: cs.aws-rds-facts
1415
tasks:
@@ -28,9 +29,9 @@
2829
region: "{{ aws_region }}"
2930
register: _ec2_list_all
3031

31-
- name: Generate list EC2 to review
32+
- name: Generate difference between both list
3233
set_fact:
33-
_ec2_untagged_list: "{{ _ec2_untagged_list + [{ 'id' : item.instance_id, 'name' : item.tags.Name }] }}"
34+
_ec2_untagged_list: "{{ _ec2_untagged_list + [{ 'id' : item.instance_id, 'name' : item.tags.Name | default('') }] }}"
3435
when: item.instance_id not in aws_ec2_whitelist
3536
with_items: "{{ _ec2_list_all.instances | difference(_ec2_list_mageops.instances) }}"
3637

@@ -41,19 +42,20 @@
4142
region: "{{ aws_region }}"
4243
register: _ec2_ebs_list
4344

44-
- name: Set unused EBS volumes
45+
- name: Set unused EBS volumes list
4546
set_fact:
46-
_ec2_ebs_list_review: "{{ _ec2_ebs_list_review + [item.id] }}"
47+
_ec2_ebs_list_to_review: "{{ _ec2_ebs_list_to_review + [item.id] }}"
4748
with_items: "{{ _ec2_ebs_list.volumes }}"
4849

49-
- name: Set _ec2_list_review
50+
- name: Generate string to EC2 end output
5051
set_fact:
51-
_ec2_list_review: "{{ _ec2_list_review | default() + 'ID : ' + item.id + ' Name : ' + item.name | default() '\n' }}"
52+
_ec2_list_to_review: "{{ (_ec2_list_to_review) }} ID : {{ item.id }} Name : {{ item.name }}"
5253
with_items: "{{ _ec2_untagged_list }}"
5354

54-
5555
- name: Failed when some resources found
5656
fail:
57-
msg: "{% if (_ec2_ebs_list.volumes | length) > 0 %} EBS volumes to review: {{ _ec2_ebs_list_review | join(',') }} \n {% endif %} \
58-
{% if (_ec2_untagged_list | length) > 0 %} EC2 instances to review: \n {{ _ec2_list_review }} {% endif %} "
57+
msg: |
58+
{% if (_ec2_ebs_list.volumes | length) > 0 %} EBS volumes to review: {{ _ec2_ebs_list_to_review | join(',') }} {% endif %}
59+
{% if (_ec2_untagged_list | length) > 0 %} EC2 instances to review:
60+
{{ _ec2_list_to_review }} {% endif %}
5961
when: "{{ (_ec2_untagged_list | length > 0) or (_ec2_ebs_list.volumes | length >0) }}"

0 commit comments

Comments
 (0)