-
Notifications
You must be signed in to change notification settings - Fork 88
/
login-roks.yml
33 lines (28 loc) · 1.25 KB
/
login-roks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
# IBM Cloud login can be unreliable at times, so we wrap the API calls in retry
# loops with a 30 second cooldown between retries, after 10 attempts we will give
# up and the task will fail
# 1. Check that we have an IBM Cloud API key defined
# -----------------------------------------------------------------------------
- name: "login-roks : Fail if ibmcloud_apikey & cluster_name are not provided"
assert:
that:
- ibmcloud_apikey is defined and ibmcloud_apikey != ""
- cluster_name is defined and cluster_name != ""
fail_msg: "ibmcloud_apikey are cluster_name properties is required"
# 2. Login to IBM Cloud
# -----------------------------------------------------------------------------
- name: "login-roks : Login to IBM Cloud"
shell: ibmcloud login -a "{{ ibmcloud_endpoint }}" --apikey "{{ ibmcloud_apikey }}" -q --no-region
register: login_result
retries: 10
delay: 30 # seconds
until: login_result.rc == 0
# 3. Configure for the selected cluster
# -----------------------------------------------------------------------------
- name: "login-roks : Set the target cluster"
shell: ibmcloud oc cluster config -c {{ cluster_name }} --admin
register: config_result
retries: 10
delay: 30 # seconds
until: config_result.rc == 0