2018-11-16 13:44:59 +01:00
|
|
|
- block:
|
|
|
|
- name: Create a namespace
|
|
|
|
k8s:
|
|
|
|
name: "{{ playbook_namespace }}"
|
2019-07-08 22:47:41 +02:00
|
|
|
kind: Namespace
|
2018-11-16 13:44:59 +01:00
|
|
|
|
2019-03-15 20:37:46 +01:00
|
|
|
- copy:
|
|
|
|
src: files
|
|
|
|
dest: "{{ remote_tmp_dir }}"
|
|
|
|
|
2018-11-16 13:44:59 +01:00
|
|
|
- name: incredibly simple ConfigMap
|
|
|
|
k8s:
|
|
|
|
definition:
|
|
|
|
apiVersion: v1
|
|
|
|
kind: ConfigMap
|
|
|
|
metadata:
|
|
|
|
name: hello
|
|
|
|
namespace: "{{ playbook_namespace }}"
|
|
|
|
validate:
|
|
|
|
fail_on_error: yes
|
|
|
|
register: k8s_with_validate
|
|
|
|
|
|
|
|
- name: assert that k8s_with_validate succeeds
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- k8s_with_validate is successful
|
|
|
|
|
|
|
|
- name: extra property does not fail without strict
|
|
|
|
k8s:
|
2019-03-15 20:37:46 +01:00
|
|
|
src: "{{ remote_tmp_dir }}/files/kuard-extra-property.yml"
|
2018-11-16 13:44:59 +01:00
|
|
|
namespace: "{{ playbook_namespace }}"
|
|
|
|
validate:
|
|
|
|
fail_on_error: yes
|
|
|
|
strict: no
|
|
|
|
|
|
|
|
- name: extra property fails with strict
|
|
|
|
k8s:
|
2019-03-15 20:37:46 +01:00
|
|
|
src: "{{ remote_tmp_dir }}/files/kuard-extra-property.yml"
|
2018-11-16 13:44:59 +01:00
|
|
|
namespace: "{{ playbook_namespace }}"
|
|
|
|
validate:
|
|
|
|
fail_on_error: yes
|
|
|
|
strict: yes
|
|
|
|
ignore_errors: yes
|
|
|
|
register: extra_property
|
|
|
|
|
|
|
|
- name: check that extra property fails with strict
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- extra_property is failed
|
|
|
|
|
|
|
|
- name: invalid type fails at validation stage
|
|
|
|
k8s:
|
2019-03-15 20:37:46 +01:00
|
|
|
src: "{{ remote_tmp_dir }}/files/kuard-invalid-type.yml"
|
2018-11-16 13:44:59 +01:00
|
|
|
namespace: "{{ playbook_namespace }}"
|
|
|
|
validate:
|
|
|
|
fail_on_error: yes
|
|
|
|
strict: no
|
|
|
|
ignore_errors: yes
|
|
|
|
register: invalid_type
|
|
|
|
|
|
|
|
- name: check that invalid type fails
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- invalid_type is failed
|
|
|
|
|
|
|
|
- name: invalid type fails with warnings when fail_on_error is False
|
|
|
|
k8s:
|
2019-03-15 20:37:46 +01:00
|
|
|
src: "{{ remote_tmp_dir }}/files/kuard-invalid-type.yml"
|
2018-11-16 13:44:59 +01:00
|
|
|
namespace: "{{ playbook_namespace }}"
|
|
|
|
validate:
|
|
|
|
fail_on_error: no
|
|
|
|
strict: no
|
|
|
|
ignore_errors: yes
|
|
|
|
register: invalid_type_no_fail
|
|
|
|
|
|
|
|
- name: check that invalid type fails
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- invalid_type_no_fail is failed
|
|
|
|
|
|
|
|
- name: setup custom resource definition
|
|
|
|
k8s:
|
2019-03-15 20:37:46 +01:00
|
|
|
src: "{{ remote_tmp_dir }}/files/setup-crd.yml"
|
2018-11-16 13:44:59 +01:00
|
|
|
|
2019-07-08 22:47:41 +02:00
|
|
|
- name: wait a few seconds
|
|
|
|
pause:
|
|
|
|
seconds: 5
|
|
|
|
|
2018-11-16 13:44:59 +01:00
|
|
|
- name: add custom resource definition
|
|
|
|
k8s:
|
2019-03-15 20:37:46 +01:00
|
|
|
src: "{{ remote_tmp_dir }}/files/crd-resource.yml"
|
2018-11-16 13:44:59 +01:00
|
|
|
namespace: "{{ playbook_namespace }}"
|
|
|
|
validate:
|
|
|
|
fail_on_error: yes
|
|
|
|
strict: yes
|
|
|
|
register: unknown_kind
|
|
|
|
|
|
|
|
- name: check that unknown kind warns
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- unknown_kind is successful
|
|
|
|
- "'warnings' in unknown_kind"
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: remove custom resource
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('file', role_path + '/files/crd-resource.yml') }}"
|
|
|
|
namespace: "{{ playbook_namespace }}"
|
|
|
|
state: absent
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: remove custom resource definitions
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('file', role_path + '/files/setup-crd.yml') }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Delete namespace
|
|
|
|
k8s:
|
|
|
|
state: absent
|
|
|
|
definition:
|
|
|
|
- kind: Namespace
|
|
|
|
apiVersion: v1
|
|
|
|
metadata:
|
|
|
|
name: "{{ playbook_namespace }}"
|
|
|
|
ignore_errors: yes
|