openshift_process fails with template does not contains message (#87)

* fix unexpected value

* changelog

* Update pod-template.yaml

* Update openshift_process.py

* Update openshift_process.py

* Update molecule/default/tasks/openshift_process.yml

Co-authored-by: Fabian von Feilitzsch <fabian@fabianism.us>

* Update pod-template.yaml

Co-authored-by: Fabian von Feilitzsch <fabian@fabianism.us>
This commit is contained in:
abikouo
2021-05-26 16:48:47 +02:00
committed by GitHub
parent 63deaeecf0
commit 4609c20a91
4 changed files with 47 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- openshift_process - fix module execution when template does not include a message (https://github.com/ansible-collections/community.okd/pull/87).

View File

@@ -0,0 +1,23 @@
---
kind: Template
apiVersion: template.openshift.io/v1
metadata:
name: pod-template
objects:
- apiVersion: v1
kind: Pod
metadata:
name: "Pod-${{ NAME }}"
spec:
containers:
- args:
- /bin/sh
- -c
- while true; do echo $(date); sleep 15; done
image: python:3.7-alpine
imagePullPolicy: Always
name: python
parameters:
- name: NAME
description: trailing name of the pod
required: true

View File

@@ -162,3 +162,22 @@
- assert:
that: result is not changed
# Processing template without message
- name: create template with file {{ files_dir }}/pod-template.yaml
kubernetes.core.k8s:
namespace: process-test
src: "{{ files_dir }}/pod-template.yaml"
state: present
- name: Process pod template
community.okd.openshift_process:
name: pod-template
namespace: process-test
state: rendered
parameters:
NAME: ansible
register: rendered_template
- assert:
that: rendered_template.message == ""

View File

@@ -330,8 +330,9 @@ class OpenShiftProcess(K8sAnsibleMixin):
except Exception as exc:
self.module.fail_json(msg="Server failed to render the Template: {0}".format(to_native(exc)),
error='', status='', reason='')
result['message'] = response['message']
result['message'] = ""
if "message" in response:
result['message'] = response['message']
result['resources'] = response['objects']
if state != 'rendered':