Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-McKanna-Test authored and audgirka committed Aug 1, 2023
1 parent 098dbc1 commit 1e98141
Showing 1 changed file with 54 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,61 +81,62 @@
index_var: index
label: "{{ platform.name }}"

- block:
- name: Destroy ephemeral EC2 instances
ec2_instance:
profile: "{{ item.aws_profile | default(omit) }}"
region: "{{ item.region | default(omit) }}"
instance_ids: "{{ instance_config | map(attribute='instance_ids') | flatten }}"
state: absent
loop: "{{ platforms }}"
loop_control:
label: "{{ item.name }}"
register: ec2_instances_async
async: 7200
poll: 0
- name: Destroy resources
when: instance_config | length != 0
block:
- name: Destroy ephemeral EC2 instances
amazon.aws.ec2_instance:
profile: "{{ item.aws_profile | default(omit) }}"
region: "{{ item.region | default(omit) }}"
instance_ids: "{{ instance_config | map(attribute='instance_ids') | flatten }}"
state: absent
loop: "{{ platforms }}"
loop_control:
label: "{{ item.name }}"
register: ec2_instances_async
async: 7200
poll: 0

- name: Wait for instance destruction to complete
async_status:
jid: "{{ item.ansible_job_id }}"
loop: "{{ ec2_instances_async.results }}"
loop_control:
index_var: index
label: "{{ platforms[index].name }}"
register: ec2_instances
until: ec2_instances is finished
retries: 300
- name: Wait for instance destruction to complete
ansible.builtin.async_status:
jid: "{{ item.ansible_job_id }}"
loop: "{{ ec2_instances_async.results }}"
loop_control:
index_var: index
label: "{{ platforms[index].name }}"
register: ec2_instances
until: ec2_instances is finished
retries: 300

- name: Write Molecule instance configs
copy:
dest: "{{ molecule_instance_config }}"
content: "{{ {} | to_yaml }}"
- name: Write Molecule instance configs
ansible.builtin.copy:
dest: "{{ molecule_instance_config }}"
content: "{{ {} | to_yaml }}"

- name: Destroy ephemeral security groups (if needed)
ec2_group:
profile: "{{ item.aws_profile | default(omit) }}"
region: "{{ item.region | default(omit) }}"
vpc_id: "{{ item.vpc_id or vpc_subnet.vpc_id }}"
name: "{{ item.security_group_name }}"
state: absent
vars:
vpc_subnet: "{{ subnet_info.results[index].subnets[0] }}"
loop: "{{ platforms }}"
loop_control:
index_var: index
label: "{{ item.name }}"
when: item.security_groups | length == 0
- name: Destroy ephemeral security groups (if needed)
amazon.aws.ec2_security_group:
profile: "{{ item.aws_profile | default(omit) }}"
region: "{{ item.region | default(omit) }}"
vpc_id: "{{ item.vpc_id or vpc_subnet.vpc_id }}"
name: "{{ item.security_group_name }}"
state: absent
vars:
vpc_subnet: "{{ subnet_info.results[index].subnets[0] }}"
loop: "{{ platforms }}"
loop_control:
index_var: index
label: "{{ item.name }}"
when: item.security_groups | length == 0

- name: Destroy ephemeral keys (if needed)
ec2_key:
profile: "{{ item.aws_profile | default(omit) }}"
region: "{{ item.region | default(omit) }}"
name: "{{ item.key_name }}"
state: absent
loop: "{{ platforms }}"
loop_control:
index_var: index
label: "{{ item.name }}"
when: item.key_inject_method == "ec2"
when: instance_config | length != 0
- name: Destroy ephemeral keys (if needed)
amazon.aws.ec2_key:
profile: "{{ item.aws_profile | default(omit) }}"
region: "{{ item.region | default(omit) }}"
name: "{{ item.key_name }}"
state: absent
loop: "{{ platforms }}"
loop_control:
index_var: index
label: "{{ item.name }}"
when: item.key_inject_method == "ec2"
{%- endraw %}

0 comments on commit 1e98141

Please sign in to comment.