Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/lightsail_snapshot/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 instance
15 lightsail:
16 name: "{{ instance_name }}"
17 zone: "{{ zone }}"
18 blueprint_id: amazon_linux_2
19 bundle_id: nano_2_0
20 wait: yes
21
22 - name: Create a new snapshot
23 lightsail_snapshot:
24 snapshot_name: "{{ snapshot_name }}"
25 instance_name: "{{ instance_name }}"
26 region: "{{ aws_region }}"
27 wait: yes
28 register: result
29
30 - assert:
31 that:
32 - result.changed == True
33 - "'instance_snapshot' in result and result.instance_snapshot.name == snapshot_name"
34 - "result.instance_snapshot.state == 'available'"
35
36 - name: Make sure instance snapshot creation is idempotent
37 lightsail_snapshot:
38 snapshot_name: "{{ snapshot_name }}"
39 instance_name: "{{ instance_name }}"
40 region: "{{ aws_region }}"
41 wait: yes
42 register: result
43
44 - assert:
45 that:
46 - result.changed == False
47
48 - name: Delete the instance snapshot
49 lightsail_snapshot:
50 snapshot_name: "{{ snapshot_name }}"
51 region: "{{ aws_region }}"
52 state: absent
53 register: result
54
55 - assert:
56 that:
57 - result.changed == True
58
59 - name: Make sure instance snapshot deletion is idempotent
60 lightsail_snapshot:
61 snapshot_name: "{{ snapshot_name }}"
62 region: "{{ aws_region }}"
63 state: absent
64 register: result
65
66 - assert:
67 that:
68 - result.changed == False
69
70 # ==== Cleanup ====================================================
71
72 always:
73
74 - name: Cleanup - delete instance snapshot
75 lightsail_snapshot:
76 snapshot_name: "{{ snapshot_name }}"
77 region: "{{ aws_region }}"
78 state: absent
79 ignore_errors: yes
80
81 - name: Cleanup - delete instance
82 lightsail:
83 name: "{{ instance_name }}"
84 state: absent
85 ignore_errors: yes