From 5e25859069248a7445ce54fd68c2d2a004888e39 Mon Sep 17 00:00:00 2001 From: Vadim Rutkovsky Date: Sun, 28 Jan 2018 14:17:04 +0100 Subject: [PATCH] Allow authenticating with Openshift via a token --- installer/check_vars/tasks/check_openshift.yml | 7 ++++--- installer/openshift/tasks/main.yml | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/installer/check_vars/tasks/check_openshift.yml b/installer/check_vars/tasks/check_openshift.yml index c8659930cb..aa13ef5a70 100644 --- a/installer/check_vars/tasks/check_openshift.yml +++ b/installer/check_vars/tasks/check_openshift.yml @@ -12,11 +12,12 @@ - openshift_user is defined and openshift_user != '' msg: "Set the value of 'openshift_user' in the inventory file." -- name: openshift_password should be defined +- name: openshift_password or openshift_token should be defined assert: that: - - openshift_password is defined and openshift_password != '' - msg: "Set the value of 'openshift_password' in the inventory file." + - (openshift_password is defined and openshift_password != '') or + (openshift_token is defined and openshift_token != '') + msg: "Set the value of 'openshift_password' or 'openshift_token' in the inventory file." - name: docker_registry should be defined if not using dockerhub assert: diff --git a/installer/openshift/tasks/main.yml b/installer/openshift/tasks/main.yml index fd6c967d24..bb70b9a6e5 100644 --- a/installer/openshift/tasks/main.yml +++ b/installer/openshift/tasks/main.yml @@ -1,6 +1,14 @@ --- -- name: Authenticate with OpenShift +- name: Authenticate with OpenShift via user and password shell: "oc login {{ openshift_host }} -u {{ openshift_user }} -p {{ openshift_password }}" + when: + - openshift_user is defined + - openshift_password is defined + - openshift_token is not defined + +- name: Authenticate with OpenShift via token + shell: "oc login {{ openshift_host }} --token {{ openshift_token }}" + when: openshift_token is defined - name: Get Project Detail shell: "oc get project {{ awx_openshift_project }}"