Fix apply patching results in check mode

apply_object returns only the patch - we need to actually
apply the patch to the existing object.

Fixes ansible/ansible#66780
This commit is contained in:
Will Thames
2020-05-04 18:48:13 +10:00
parent a23d454365
commit 34137c40c2
2 changed files with 7 additions and 1 deletions

View File

@@ -21,6 +21,8 @@ provisioner:
ansible_python_interpreter: '{{ ansible_playbook_python }}'
env:
ANSIBLE_FORCE_COLOR: 'true'
options:
vvv: True
scenario:
name: default
test_sequence:

View File

@@ -299,7 +299,11 @@ class KubernetesRawModule(KubernetesAnsibleModule):
else:
if self.apply:
if self.check_mode:
ignored, k8s_obj = apply_object(resource, definition)
ignored, patch = apply_object(resource, definition)
if existing:
k8s_obj = dict_merge(existing.to_dict(), patch)
else:
k8s_obj = patch
else:
try:
k8s_obj = resource.apply(definition, namespace=namespace).to_dict()