forked from pavelanni/ocp4-deployment-homework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_users.yml
47 lines (41 loc) · 1009 Bytes
/
add_users.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
34
35
36
37
38
39
40
41
42
43
44
45
46
---
- hosts: localhost
tasks:
- name: Add users to password file
htpasswd:
path: files/passwdfile
name: "{{ item }}"
password: 'openshift4'
loop:
- john
- paul
- ringo
- george
- pete
- name: Create the htpasswd Secret YAML
template:
src: files/htpasswd-secret.yaml.j2
dest: files/htpasswd-secret.yaml
vars:
htpasswd_var: "{{ lookup('file', 'files/passwdfile') }}"
htpasswd_encoded: "{{ htpasswd_var | b64encode }}"
- name: Create the htpasswd Secret
k8s:
state: present
src: files/htpasswd-secret.yaml
- name: Create the htpasswd CR
k8s:
state: present
src: files/htpasswd-cr.yaml
- name: Make user john cluster-admin
k8s:
state: present
src: files/cluster-admin-rolebinding.yaml
- name: Login to the cluster with each user
command: oc login -u {{ item }} -p openshift4
loop:
- paul
- ringo
- george
- pete
- john