fix bug - k8s was crashing when yaml ended with 3 dashes (#61182)

* fix bug - k8s was crashing when yaml ended with 3 dashes

* #61182 - add changelog
pull/61314/head
Michał Szczepańczyk 5 years ago committed by Will Thames
parent 7e1a347695
commit 8ed3a0b360

@ -0,0 +1,2 @@
bugfixes:
- k8s module - fix for case when resource definition yaml ended with 3 dashes

@ -136,6 +136,10 @@ class KubernetesRawModule(KubernetesAnsibleModule):
src = self.params.get('src')
if src:
self.resource_definitions = self.load_resource_definitions(src)
try:
self.resource_definitions = [item for item in self.resource_definitions if item]
except AttributeError:
pass
if not resource_definition and not src:
implicit_definition = dict(

@ -312,12 +312,29 @@
- testing5
register: k8s_info
- name: Resources are terminating if still in results
assert:
that: not item.resources or item.resources[0].status.phase == "Terminating"
loop: "{{ k8s_info.results }}"
- name: Create resources from a yaml string ending with ---
k8s:
definition: |+
---
kind: Namespace
apiVersion: v1
metadata:
name: testing6
---
- name: Namespace should exist
k8s_info:
kind: Namespace
api_version: v1
name: testing6
register: k8s_info_testing6
failed_when: not k8s_info_testing6.resources or k8s_info_testing6.resources[0].status.phase != "Active"
- include_tasks: crd.yml
- include_tasks: lists.yml
- include_tasks: append_hash.yml
@ -351,4 +368,8 @@
apiVersion: v1
metadata:
name: testing5
- kind: Namespace
apiVersion: v1
metadata:
name: testing6
ignore_errors: yes

Loading…
Cancel
Save