Skip to content

Commit f573f6d

Browse files
tjmoore4jkatz
authored andcommitted
Improvements to Postgres Operator Ansible Inventory Validation
These changes improve the inventory validation to better ensure the appropriate values are set before completing an Openshift or Kubernetes Operator install. Most of the checking now happens during preflight, meaning the problems are identified earlier. Additionally, there are checks to see that the required values are not just set but are also not null.
1 parent 672c550 commit f573f6d

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

ansible/roles/pgo-preflight/tasks/check_openshift.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# check_openshift.yml
22
---
3+
- name: openshift_token should be defined
4+
assert:
5+
that:
6+
- openshift_token != ''
7+
msg: "Set the value of 'openshift_token' in the inventory file."
8+
when:
9+
- openshift_token is defined
10+
tags: always
11+
312
- name: openshift_user should be defined
413
assert:
514
that:
@@ -16,16 +25,6 @@
1625
when: openshift_token is not defined
1726
tags: always
1827

19-
- name: openshift_token should be defined
20-
assert:
21-
that:
22-
- openshift_token is defined and openshift_token != ''
23-
msg: "Set the value of 'openshift_token' in the inventory file."
24-
when:
25-
- openshift_user is not defined
26-
- openshift_password is not defined
27-
tags: always
28-
2928
- name: Check if the oc command is installed
3029
shell: which oc
3130
register: oc_result

ansible/roles/pgo-preflight/tasks/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
- name: Check if required Kube or OpenShift variables are defined
1313
fail: msg="Please specify either OpenShift or Kubernetes variables in inventory"
14-
when: openshift_user is undefined and openshift_host is undefined and openshift_token is undefined and kubernetes_context is undefined
14+
when: >
15+
(openshift_host is undefined or (openshift_host is defined and openshift_host == ''))
16+
and (kubernetes_context is undefined or (kubernetes_context is defined and kubernetes_context == ''))
17+
or ((openshift_host is defined and openshift_host != '') and (kubernetes_context is defined and kubernetes_context != ''))
1518
tags: always
1619

1720
- include_tasks: check_openshift.yml

0 commit comments

Comments
 (0)