-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73384be
commit bf6ab24
Showing
12 changed files
with
173 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
18 changes: 18 additions & 0 deletions
18
automation-generators/generic/openshift_redhat_sso/preprocessor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from generatorPreProcessor import GeneratorPreProcessor | ||
import sys | ||
|
||
# Validating: | ||
# --- | ||
# openshift_sso: | ||
# - openshift_cluster_name: {{ env_id }} | ||
|
||
def preprocessor(attributes=None, fullConfig=None, moduleVariables=None): | ||
g = GeneratorPreProcessor(attributes,fullConfig,moduleVariables) | ||
|
||
g('openshift_cluster_name').isRequired() | ||
|
||
result = { | ||
'attributes_updated': g.getExpandedAttributes(), | ||
'errors': g.getErrors() | ||
} | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: Generate yaml for Keycloak {{ _current_keycloak.name }} | ||
template: | ||
src: redhat-sso-keycloak.j2 | ||
dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _current_keycloak.name }}-keycloak.yaml" | ||
|
||
- name: Create Keycloak from YAML file {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _current_keycloak.name }}-keycloak.yaml | ||
shell: | | ||
oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _current_keycloak.name }}-keycloak.yaml | ||
- name: Wait until Keycloak {{ _current_keycloak.name }} is ready | ||
shell: | | ||
oc get Keycloak -n {{ _v_redhat_sso_project }} {{ _current_keycloak.name }} \ | ||
-o jsonpath='{.status.ready}' | ||
register: _keycloak_status | ||
retries: 30 | ||
delay: 30 | ||
until: (_keycloak_status.stdout | lower) == "true" | ||
vars: | ||
ansible_callback_diy_runner_retry_msg: >- | ||
{%- set result = ansible_callback_diy.result.output -%} | ||
{%- set retries_left = result.retries - result.attempts -%} | ||
Retrying: {{ ansible_callback_diy.task.name }} ({{ retries_left }} Retries left) ... |
6 changes: 6 additions & 0 deletions
6
automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloaks.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Provision Keycloak CRs | ||
include_tasks: configure-keycloak.yml | ||
loop: "{{ _p_openshift_redhat_sso.keycloak | default([]) }}" | ||
loop_control: | ||
loop_var: _current_keycloak |
44 changes: 44 additions & 0 deletions
44
...on-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
- name: Generate yaml for redhat-sso namespace | ||
template: | ||
src: redhat-sso-namespace.j2 | ||
dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-redhat-sso-namespace.yaml" | ||
- name: Create redhat-sso namespace | ||
shell: | | ||
oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-redhat-sso-namespace.yaml | ||
- name: Generate yaml for Red Hat SSO operator group | ||
template: | ||
src: redhat-sso-operatorgroup.j2 | ||
dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-redhat-sso-operatorgroup.yaml" | ||
|
||
- name: Create redhat-sso operatorgroup | ||
shell: | | ||
oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-redhat-sso-operatorgroup.yaml | ||
- name: Generate yaml for Red Hat SSO subscription | ||
template: | ||
src: redhat-sso-subscription.j2 | ||
dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-redhat-sso-subscription.yaml" | ||
|
||
- name: Create redhat-sso operator | ||
shell: | | ||
oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-redhat-sso-subscription.yaml | ||
# Wait until subscription has been successfully created | ||
- name: Wait until Red Hat SSO has status Succeeded | ||
shell: | | ||
oc get csv -n {{ _v_redhat_sso_project }} \ | ||
-l operators.coreos.com/rhsso-operator.redhat-sso \ | ||
--no-headers \ | ||
-o custom-columns='name:metadata.name,phase:status.phase' | \ | ||
grep -i succeeded | wc -l | ||
register: _redhat_sso_csv_status | ||
retries: 30 | ||
delay: 30 | ||
until: _redhat_sso_csv_status.stdout == "1" | ||
vars: | ||
ansible_callback_diy_runner_retry_msg: >- | ||
{%- set result = ansible_callback_diy.result.output -%} | ||
{%- set retries_left = result.retries - result.attempts -%} | ||
Retrying: {{ ansible_callback_diy.task.name }} ({{ retries_left }} Retries left) ... |
22 changes: 22 additions & 0 deletions
22
automation-roles/40-configure-infra/openshift-redhat-sso/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- set_fact: | ||
_p_openshift_redhat_sso: {} | ||
|
||
- when: "all_config.openshift_redhat_sso is defined" | ||
block: | ||
- debug: | ||
var: all_config.openshift_redhat_sso | ||
- set_fact: | ||
_p_openshift_redhat_sso: "{{ all_config.openshift_redhat_sso | json_query(query) | first | default({}) }}" | ||
vars: | ||
query: >- | ||
[?openshift_cluster_name=='{{ current_openshift_cluster.name }}'] | ||
- name: Show OpenShift Red Hat SSO for current cluster | ||
debug: | ||
var: _p_openshift_redhat_sso | ||
|
||
- include_tasks: configure-openshift-redhat-sso.yml | ||
when: _p_openshift_redhat_sso != {} | ||
|
||
- include_tasks: configure-keycloaks.yml | ||
when: _p_openshift_redhat_sso != {} |
16 changes: 16 additions & 0 deletions
16
automation-roles/40-configure-infra/openshift-redhat-sso/templates/redhat-sso-keycloak.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
apiVersion: keycloak.org/v1alpha1 | ||
kind: Keycloak | ||
metadata: | ||
name: {{ _current_keycloak.name }} | ||
labels: | ||
app: sso | ||
namespace: {{ _v_redhat_sso_project }} | ||
spec: | ||
externalAccess: | ||
enabled: true | ||
keycloakDeploymentSpec: | ||
imagePullPolicy: Always | ||
postgresDeploymentSpec: | ||
imagePullPolicy: Always | ||
instances: 1 |
6 changes: 6 additions & 0 deletions
6
automation-roles/40-configure-infra/openshift-redhat-sso/templates/redhat-sso-namespace.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: {{ _v_redhat_sso_project }} | ||
annotations: | ||
openshift.io/node-selector: "" |
8 changes: 8 additions & 0 deletions
8
...ation-roles/40-configure-infra/openshift-redhat-sso/templates/redhat-sso-operatorgroup.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: operators.coreos.com/v1 | ||
kind: OperatorGroup | ||
metadata: | ||
name: redhat-sso-og | ||
namespace: {{ _v_redhat_sso_project }} | ||
spec: | ||
targetNamespaces: | ||
- {{ _v_redhat_sso_project }} |
11 changes: 11 additions & 0 deletions
11
...mation-roles/40-configure-infra/openshift-redhat-sso/templates/redhat-sso-subscription.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: operators.coreos.com/v1alpha1 | ||
kind: Subscription | ||
metadata: | ||
name: redhat-sso | ||
namespace: {{ _v_redhat_sso_project }} | ||
spec: | ||
channel: stable | ||
name: rhsso-operator | ||
source: redhat-operators | ||
sourceNamespace: openshift-marketplace | ||
installPlanApproval: Automatic |
1 change: 1 addition & 0 deletions
1
automation-roles/40-configure-infra/openshift-redhat-sso/vars/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_v_redhat_sso_project: redhat-sso |