From 34137c40c220170dd1c6c2bc6c2d2fef834200b7 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Mon, 4 May 2020 18:48:13 +1000 Subject: [PATCH] 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 --- molecule/default/molecule.yml | 2 ++ plugins/module_utils/raw.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 90ba2e53..37f7c3bc 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -21,6 +21,8 @@ provisioner: ansible_python_interpreter: '{{ ansible_playbook_python }}' env: ANSIBLE_FORCE_COLOR: 'true' + options: + vvv: True scenario: name: default test_sequence: diff --git a/plugins/module_utils/raw.py b/plugins/module_utils/raw.py index de214e90..929193b1 100644 --- a/plugins/module_utils/raw.py +++ b/plugins/module_utils/raw.py @@ -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()