Debian Codegraph @

ansible_collections/community/okd/molecule/default/tasks/validate_installed.yml

raw
1 ---
2 - block:
3 - name: Create a project
4 community.okd.k8s:
5 name: "{{ playbook_namespace }}"
6 kind: Project
7 api_version: project.openshift.io/v1
8
9 - name: incredibly simple ConfigMap
10 community.okd.k8s:
11 definition:
12 apiVersion: v1
13 kind: ConfigMap
14 metadata:
15 name: hello
16 namespace: "{{ playbook_namespace }}"
17 validate:
18 fail_on_error: yes
19 register: k8s_with_validate
20
21 - name: assert that k8s_with_validate succeeds
22 assert:
23 that:
24 - k8s_with_validate is successful
25
26 - name: extra property does not fail without strict
27 community.okd.k8s:
28 src: "files/kuard-extra-property.yml"
29 namespace: "{{ playbook_namespace }}"
30 validate:
31 fail_on_error: yes
32 strict: no
33
34 - name: extra property fails with strict
35 community.okd.k8s:
36 src: "files/kuard-extra-property.yml"
37 namespace: "{{ playbook_namespace }}"
38 validate:
39 fail_on_error: yes
40 strict: yes
41 ignore_errors: yes
42 register: extra_property
43
44 - name: check that extra property fails with strict
45 assert:
46 that:
47 - extra_property is failed
48
49 - name: invalid type fails at validation stage
50 community.okd.k8s:
51 src: "files/kuard-invalid-type.yml"
52 namespace: "{{ playbook_namespace }}"
53 validate:
54 fail_on_error: yes
55 strict: no
56 ignore_errors: yes
57 register: invalid_type
58
59 - name: check that invalid type fails
60 assert:
61 that:
62 - invalid_type is failed
63
64 - name: invalid type fails with warnings when fail_on_error is False
65 community.okd.k8s:
66 src: "files/kuard-invalid-type.yml"
67 namespace: "{{ playbook_namespace }}"
68 validate:
69 fail_on_error: no
70 strict: no
71 ignore_errors: yes
72 register: invalid_type_no_fail
73
74 - name: check that invalid type fails
75 assert:
76 that:
77 - invalid_type_no_fail is failed
78
79 - name: setup custom resource definition
80 community.okd.k8s:
81 src: "files/setup-crd.yml"
82
83 - name: wait a few seconds
84 pause:
85 seconds: 5
86
87 - name: add custom resource definition
88 community.okd.k8s:
89 src: "files/crd-resource.yml"
90 namespace: "{{ playbook_namespace }}"
91 validate:
92 fail_on_error: yes
93 strict: yes
94 register: unknown_kind
95
96 - name: check that unknown kind warns
97 assert:
98 that:
99 - unknown_kind is successful
100
101 always:
102 - name: remove custom resource
103 community.okd.k8s:
104 definition: "{{ lookup('file', 'files/crd-resource.yml') }}"
105 namespace: "{{ playbook_namespace }}"
106 state: absent
107 ignore_errors: yes
108
109 - name: remove custom resource definitions
110 community.okd.k8s:
111 definition: "{{ lookup('file', 'files/setup-crd.yml') }}"
112 state: absent
113
114 - name: Delete namespace
115 community.okd.k8s:
116 state: absent
117 definition:
118 - kind: Project
119 apiVersion: project.openshift.io/v1
120 metadata:
121 name: "{{ playbook_namespace }}"
122 ignore_errors: yes