mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
aaf29c785f
* Provide Kubernetes resource validation to k8s module Use kubernetes-validate to validate Kubernetes resource definitions against the published schema * Additional tests for kubernetes-validate * Improve k8s error messages on exceptions Parse the response body for the message rather than returning a JSON blob If we've validated and there are warnings, return those too - they can be more helpful ``` "msg": "Failed to patch object: {\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{}, \"status\":\"Failure\",\"message\":\"[pos 334]: json: decNum: got first char 'h'\",\"code\":500}\n", ``` vs ``` "msg": "Failed to patch object: [pos 334]: json: decNum: got first char 'h'\nresource validation error at spec.replicas: 'hello' is not of type u'integer'", ``` * Update versions used In particular openshift/origin:3.9.0 * Add changelog for k8s validate change
61 lines
1.6 KiB
YAML
61 lines
1.6 KiB
YAML
- hosts: localhost
|
|
connection: local
|
|
gather_facts: no
|
|
vars:
|
|
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
|
recreate_crd_default_merge_expectation: recreate_crd is failed
|
|
playbook_namespace: ansible-test-k8s-older-openshift
|
|
|
|
tasks:
|
|
- python_requirements_facts:
|
|
dependencies:
|
|
- openshift==0.6.0
|
|
- kubernetes==6.0.0
|
|
|
|
# append_hash
|
|
- name: use append_hash with ConfigMap
|
|
k8s:
|
|
definition:
|
|
metadata:
|
|
name: config-map-test
|
|
namespace: "{{ playbook_namespace }}"
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
data:
|
|
hello: world
|
|
append_hash: yes
|
|
ignore_errors: yes
|
|
register: k8s_append_hash
|
|
|
|
- name: assert that append_hash fails gracefully
|
|
assert:
|
|
that:
|
|
- k8s_append_hash is failed
|
|
- "k8s_append_hash.msg == 'openshift >= 0.7.FIXME is required for append_hash'"
|
|
|
|
# merge_type
|
|
- include_role:
|
|
name: k8s
|
|
tasks_from: crd
|
|
|
|
# validate
|
|
- name: attempt to use validate with older openshift
|
|
k8s:
|
|
definition:
|
|
metadata:
|
|
name: config-map-test
|
|
namespace: "{{ playbook_namespace }}"
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
data:
|
|
hello: world
|
|
validate:
|
|
fail_on_error: yes
|
|
ignore_errors: yes
|
|
register: k8s_validate
|
|
|
|
- name: assert that validate fails gracefully
|
|
assert:
|
|
that:
|
|
- k8s_validate is failed
|
|
- "k8s_validate.msg == 'openshift >= 0.7.FIXME is required for validate'"
|