Debian Codegraph @

ansible_collections/amazon/aws/tests/integration/targets/ec2_eni/tasks/test_deletion.yaml

raw
1 ---
2 # ============================================================
3 - name: Test deleting the unattached network interface by using the ID (check mode)
4 amazon.aws.ec2_eni:
5 eni_id: "{{ eni_id_1 }}"
6 name: "{{ resource_prefix }}"
7 subnet_id: "{{ vpc_subnet_id }}"
8 state: absent
9 check_mode: true
10 register: result_check_mode
11
12 - ansible.builtin.assert:
13 that:
14 - result_check_mode.changed
15
16 - name: Test deleting the unattached network interface by using the ID
17 amazon.aws.ec2_eni:
18 eni_id: "{{ eni_id_1 }}"
19 name: "{{ resource_prefix }}"
20 subnet_id: "{{ vpc_subnet_id }}"
21 state: absent
22 register: result
23 - amazon.aws.ec2_eni_info:
24 eni_id: "{{ eni_id_1 }}"
25 register: eni_info
26
27 - ansible.builtin.assert:
28 that:
29 - result.changed
30 - result.interface is undefined
31 - '"network_interfaces" in eni_info'
32 - eni_id_1 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
33
34 - name: Test removing the network interface by ID is idempotent (check mode)
35 amazon.aws.ec2_eni:
36 eni_id: "{{ eni_id_1 }}"
37 name: "{{ resource_prefix }}"
38 subnet_id: "{{ vpc_subnet_id }}"
39 state: absent
40 check_mode: true
41 register: result_check_mode
42
43 - ansible.builtin.assert:
44 that:
45 - not result_check_mode.changed
46
47 - name: Test removing the network interface by ID is idempotent
48 amazon.aws.ec2_eni:
49 eni_id: "{{ eni_id_1 }}"
50 name: "{{ resource_prefix }}"
51 subnet_id: "{{ vpc_subnet_id }}"
52 state: absent
53 register: result
54
55 - ansible.builtin.assert:
56 that:
57 - not result.changed
58 - result.interface is undefined
59
60 # ============================================================
61 - name: Add a name tag to the other network interface before deleting it
62 amazon.aws.ec2_eni:
63 eni_id: "{{ eni_id_2 }}"
64 name: "{{ resource_prefix }}"
65 state: present
66
67 - name: Test deleting the unattached network interface by using the name
68 amazon.aws.ec2_eni:
69 name: "{{ resource_prefix }}"
70 subnet_id: "{{ vpc_subnet_id }}"
71 state: absent
72 register: result
73 - amazon.aws.ec2_eni_info:
74 eni_id: "{{ eni_id_2 }}"
75 register: eni_info
76
77 - ansible.builtin.assert:
78 that:
79 - result.changed
80 - result.interface is undefined
81 - '"network_interfaces" in eni_info'
82 - eni_id_2 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
83
84 - name: Test removing the network interface by name is idempotent
85 amazon.aws.ec2_eni:
86 name: "{{ resource_prefix }}"
87 subnet_id: "{{ vpc_subnet_id }}"
88 state: absent
89 register: result
90
91 - ansible.builtin.assert:
92 that:
93 - not result.changed
94 - result.interface is undefined
95
96 - name: Verify that the network interface ID does not exist (retry-delete by ID)
97 amazon.aws.ec2_eni:
98 eni_id: "{{ eni_id_2 }}"
99 state: absent
100 register: result
101
102 - ansible.builtin.assert:
103 that:
104 - not result.changed
105 - result.interface is undefined
106
107 # ============================================================
108
109 - name: Fetch ENI info without filter
110 amazon.aws.ec2_eni_info:
111 register: eni_info
112
113 - name: Assert that ec2_eni_info doesn't contain the two interfaces we just deleted
114 ansible.builtin.assert:
115 that:
116 - '"network_interfaces" in eni_info'
117 - eni_id_1 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )
118 - eni_id_2 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list )