Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/lightsail_static_ip/tasks/main.yml

raw
1 ---
2
3 - module_defaults:
4 group/aws:
5 access_key: '{{ aws_access_key }}'
6 secret_key: '{{ aws_secret_key }}'
7 session_token: '{{ security_token | default(omit) }}'
8 region: '{{ aws_region }}'
9
10 block:
11
12 # ==== Tests ===================================================
13
14 - name: Create a new static IP
15 lightsail_static_ip:
16 name: "{{ static_ip_name }}"
17 register: result
18
19 - assert:
20 that:
21 - result.changed == True
22 - '"static_ip" in result'
23 - '"arn" in result.static_ip'
24 - '"created_at" in result.static_ip'
25 - '"ip_address" in result.static_ip'
26 - '"is_attached" in result.static_ip'
27 - '"location" in result.static_ip'
28 - '"name" in result.static_ip'
29 - '"resource_type" in result.static_ip'
30 - '"support_code" in result.static_ip'
31 - result.static_ip.arn.startswith("arn:")
32 - result.static_ip.name == static_ip_name
33 - result.static_ip.resource_type == 'StaticIp'
34 - result.static_ip.is_attached == false
35 - result.static_ip.ip_address | ansible.utils.ipaddr == result.static_ip.ip_address
36 - '"availability_zone" in result.static_ip.location'
37 - '"region_name" in result.static_ip.location'
38
39 - set_fact:
40 lightsail_ip_arn: '{{ result.static_ip.arn }}'
41 lightsail_ip_address: '{{ result.static_ip.ip_address }}'
42
43 - name: Make sure create is idempotent
44 lightsail_static_ip:
45 name: "{{ static_ip_name }}"
46 register: result
47
48 - assert:
49 that:
50 - result.changed == False
51 - '"static_ip" in result'
52 - '"arn" in result.static_ip'
53 - '"created_at" in result.static_ip'
54 - '"ip_address" in result.static_ip'
55 - '"is_attached" in result.static_ip'
56 - '"location" in result.static_ip'
57 - '"name" in result.static_ip'
58 - '"resource_type" in result.static_ip'
59 - '"support_code" in result.static_ip'
60 - result.static_ip.arn == lightsail_ip_arn
61 - result.static_ip.name == static_ip_name
62 - result.static_ip.resource_type == 'StaticIp'
63 - result.static_ip.is_attached == false
64 - result.static_ip.ip_address == lightsail_ip_address
65 - '"availability_zone" in result.static_ip.location'
66 - '"region_name" in result.static_ip.location'
67
68 - name: Delete the static IP
69 lightsail_static_ip:
70 name: "{{ static_ip_name }}"
71 state: absent
72 register: result
73
74 - assert:
75 that:
76 - result.changed == True
77
78 - name: Make sure deletion is idempotent
79 lightsail_static_ip:
80 name: "{{ static_ip_name }}"
81 state: absent
82 register: result
83
84 - assert:
85 that:
86 - result.changed == False
87
88 # ==== Cleanup ====================================================
89
90 always:
91
92 - name: Cleanup - delete static IP
93 lightsail_static_ip:
94 name: "{{ static_ip_name }}"
95 state: absent
96 ignore_errors: yes