Skip to content

Commit 86784fd

Browse files
authored
Generate OCP admin credentials (#12)
1 parent 500757c commit 86784fd

File tree

8 files changed

+43
-1
lines changed

8 files changed

+43
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# generate-ocp-admin-credentials
2+
3+
An Ansible playbook for generating the `ocp-admin-credentials.json` file for OCP resources to be consumed by other operators & tools.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ansible_connection: local
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[local]
2+
localhost
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- name: Generate admin password for OCP
3+
hosts: local
4+
gather_facts: false
5+
tasks:
6+
- name: Set credentials file
7+
set_fact:
8+
ocp_credentials_file: "{{ directory }}/ocp-admin-credentials.json"
9+
- name: Check if credentials file already exist
10+
stat:
11+
path: "{{ ocp_credentials_file }}"
12+
register: r_ocp_credentials_file
13+
- name: Read Engagement Data
14+
include_vars:
15+
file: "{{ directory }}/engagement.json"
16+
- name: Only if credentials haven't already been created
17+
block:
18+
- name: Create OCP password
19+
set_fact:
20+
ocp_password: "{{ lookup('password', '/dev/null length=32') }}"
21+
- name: Create OCP credentials file
22+
copy:
23+
dest: "{{ ocp_credentials_file }}"
24+
content: "{{ {'ocp_admin_username':'admin','ocp_admin_password':ocp_password } | to_nice_json }}"
25+
when:
26+
- r_ocp_credentials_file.stat.exists == False
27+
- ocp_version is defined

translate-engagement-data/files/ocp-init/templates/resourceclaim.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ spec:
2020
governor: labs.ocp4.na
2121
vars:
2222
job_vars:
23+
admin_user: {{ .Values.ocp.admin_username }}
24+
admin_password: {{ .Values.ocp.admin_password }}
2325
aws_region: {{ .Values.ocp.cloud_region }}
2426
ocp4_installer_version: {{ .Values.ocp.version }}
2527
ocp_subdomain: {{ .Values.ocp.sub_domain }}

translate-engagement-data/files/ocp-init/values.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
email: {{ engagement_lead_email }}
22
ocp:
3+
admin_username: {{ ocp_admin_username }}
4+
admin_password: {{ ocp_admin_password }}
35
cloud_provider: {{ ocp_cloud_provider_name }}
46
cloud_region: {{ ocp_cloud_provider_region }}
57
cluster_size: {{ ocp_cluster_size }}

translate-engagement-data/site.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
- name: Read Engagement Data
77
include_vars:
88
file: "{{ directory }}/engagement.json"
9+
- name: Read OCP credentials
10+
include_vars:
11+
file: "{{ directory }}/ocp-admin-credentials.json"
12+
when: ocp_version is defined
913
- name: Create OCP Chart directory if not exists
1014
file:
1115
path: "{{ directory }}/ocp-init"
@@ -25,4 +29,4 @@
2529
src: "{{ item }}"
2630
dest: "{{ directory }}/ocp-init/templates/{{ item | basename | regex_replace('\\.j2$', '.yaml') }}"
2731
with_fileglob:
28-
- ocp-init/templates/*.j2
32+
- ocp-init/templates/*.j2

0 commit comments

Comments
 (0)