2018-09-08 02:08:09 +02:00
|
|
|
# TODO: This is the only way I could get the kubeconfig, I don't know why. Running the lookup outside of debug seems to return an empty string
|
|
|
|
#- debug: msg={{ lookup('env', 'K8S_AUTH_KUBECONFIG') }}
|
|
|
|
# register: kubeconfig
|
|
|
|
|
|
|
|
# Kubernetes resources
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Create a namespace
|
|
|
|
k8s:
|
2018-11-13 13:50:15 +01:00
|
|
|
name: crd
|
2019-07-08 22:47:41 +02:00
|
|
|
kind: Namespace
|
2018-09-08 02:08:09 +02:00
|
|
|
|
|
|
|
- name: install custom resource definitions
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('file', role_path + '/files/setup-crd.yml') }}"
|
|
|
|
|
2019-07-08 22:47:41 +02:00
|
|
|
- name: pause 5 seconds to avoid race condition
|
|
|
|
pause:
|
|
|
|
seconds: 5
|
|
|
|
|
2018-09-08 02:08:09 +02:00
|
|
|
- name: create custom resource definition
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('file', role_path + '/files/crd-resource.yml') }}"
|
2018-11-13 13:50:15 +01:00
|
|
|
namespace: crd
|
2019-07-08 22:47:41 +02:00
|
|
|
apply: "{{ create_crd_with_apply | default(omit) }}"
|
2018-09-08 02:08:09 +02:00
|
|
|
register: create_crd
|
|
|
|
|
|
|
|
- name: patch custom resource definition
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('file', role_path + '/files/crd-resource.yml') }}"
|
2018-11-13 13:50:15 +01:00
|
|
|
namespace: crd
|
2018-09-08 02:08:09 +02:00
|
|
|
register: recreate_crd
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: assert that recreating crd is as expected
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- recreate_crd_default_merge_expectation
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: recreate custom resource definition with merge_type
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('file', role_path + '/files/crd-resource.yml') }}"
|
|
|
|
merge_type: merge
|
2018-11-13 13:50:15 +01:00
|
|
|
namespace: crd
|
2018-09-08 02:08:09 +02:00
|
|
|
register: recreate_crd_with_merge
|
|
|
|
|
|
|
|
- name: recreate custom resource definition with merge_type list
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('file', role_path + '/files/crd-resource.yml') }}"
|
|
|
|
merge_type:
|
|
|
|
- strategic-merge
|
|
|
|
- merge
|
2018-11-13 13:50:15 +01:00
|
|
|
namespace: crd
|
2018-09-08 02:08:09 +02:00
|
|
|
register: recreate_crd_with_merge_list
|
|
|
|
when: recreate_crd is successful
|
|
|
|
|
|
|
|
|
|
|
|
- name: remove crd
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('file', role_path + '/files/crd-resource.yml') }}"
|
2018-11-13 13:50:15 +01:00
|
|
|
namespace: crd
|
2018-09-08 02:08:09 +02:00
|
|
|
state: absent
|
|
|
|
|
|
|
|
always:
|
2018-11-13 13:50:15 +01:00
|
|
|
- name: remove crd namespace
|
2018-09-08 02:08:09 +02:00
|
|
|
k8s:
|
2018-11-13 13:50:15 +01:00
|
|
|
kind: Namespace
|
|
|
|
name: crd
|
2018-09-08 02:08:09 +02:00
|
|
|
state: absent
|
|
|
|
ignore_errors: yes
|