5 changed files with 111 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||
--- |
|||
|
|||
- name: Retrieve current ReplicationController status |
|||
command: 'oc get rc -o json -n "{{ project }}"' |
|||
register: rc_state |
|||
changed_when: false |
|||
|
|||
- name: Parse the list of deployed ReplicationController |
|||
set_fact: |
|||
replication_controllers: '{{ rc_state.stdout |from_json |json_query(''items[? @.status.replicas && @.status.replicas != `0`].metadata.annotations."openshift.io/deployment-config.name"'') }}' |
|||
replication_controllers_status: '{{ rc_state.stdout |from_json |json_query(''items[? @.status.replicas && @.status.replicas != `0`].{"name": metadata.annotations."openshift.io/deployment-config.name", "status": status.readyReplicas}'') }}' |
|||
|
|||
|
|||
- name: Retrieve current DeploymentConfig status |
|||
command: 'oc get dc -o json -n "{{ project }}"' |
|||
register: dc_state |
|||
changed_when: false |
|||
|
|||
- name: Parse the list of DeploymentConfig |
|||
set_fact: |
|||
deployment_configs: '{{ dc_state.stdout |from_json |json_query(''items[? metadata.generation > `1`].metadata.name'') }}' |
|||
deployment_configs_status: '{{ dc_state.stdout |from_json |json_query(''items[? metadata.generation > `1` ].{"name": metadata.name, "status": status.replicas}'') }}' |
|||
@ -0,0 +1,9 @@ |
|||
--- |
|||
|
|||
- name: Wait for all pending deployments to become ready |
|||
command: 'oc get rc -o json -n "{{ project }}"' |
|||
register: rc_state |
|||
changed_when: false |
|||
retries: "{{ retries }}" |
|||
delay: "{{ delay }}" |
|||
until: 'rc_state.stdout |from_json |json_query(''items[? status.replicas != `0` && (status.readyReplicas == ""|| status.readyReplicas == `0`) ].metadata.annotations."openshift.io/deployment-config.name"'') |intersect(pod_to_wait) |length == 0' |
|||
@ -0,0 +1,8 @@ |
|||
--- |
|||
|
|||
itix_sso_template: sso71-allinone |
|||
itix_sso_project: sso |
|||
itix_sso_realm: itix |
|||
itix_sso_application_name: sso |
|||
itix_sso_retries: 30 |
|||
itix_sso_delay: 5 |
|||
@ -0,0 +1,64 @@ |
|||
--- |
|||
|
|||
- name: Get a list of existing projects |
|||
command: oc get projects -o name |
|||
register: oc_get_projects |
|||
changed_when: false |
|||
|
|||
- name: Create a new project for SSO |
|||
command: oc new-project "{{ itix_sso_project }}" |
|||
when: '"projects/" ~ itix_sso_project not in oc_get_projects.stdout_lines' |
|||
|
|||
- name: Query existing deploymentconfigs |
|||
command: oc get dc -n "{{ itix_sso_project }}" -o name -l "application={{ itix_sso_application_name }}" |
|||
register: oc_get_dc |
|||
changed_when: false |
|||
|
|||
- name: Deploy app if needed |
|||
set_fact: |
|||
deploy_needed: "{{ 'deploymentconfigs/' ~ itix_sso_application_name not in oc_get_dc.stdout_lines }}" |
|||
|
|||
- name: Process the OpenShift Template and create the OpenShift objects |
|||
command: oc new-app -n {{ itix_sso_project }} {{ itix_sso_template }} -p "SSO_HOSTNAME={{ itix_sso_hostname }}" -p "APPLICATION_NAME={{ itix_sso_application_name }}" |
|||
when: deploy_needed |
|||
|
|||
- name: Wait for OpenShift to create all objects |
|||
pause: |
|||
seconds: '{{ itix_sso_delay }}' |
|||
when: deploy_needed |
|||
|
|||
- include: common/wait_for.yml |
|||
static: no |
|||
vars: |
|||
pod_to_wait: |
|||
- sso |
|||
- sso-postgresql |
|||
delay: "{{ itix_sso_delay }}" |
|||
retries: "{{ itix_sso_retries }}" |
|||
project: "{{ itix_sso_project }}" |
|||
tags: status |
|||
|
|||
- name: Get Admin Username |
|||
command: oc get dc {{ itix_sso_application_name }} -n "{{ itix_sso_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="SSO_ADMIN_USERNAME")].value}' |
|||
register: username |
|||
changed_when: false |
|||
tags: status |
|||
|
|||
- name: Get Admin Password |
|||
command: oc get dc {{ itix_sso_application_name }} -n "{{ itix_sso_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="SSO_ADMIN_PASSWORD")].value}' |
|||
register: password |
|||
changed_when: false |
|||
tags: status |
|||
|
|||
- name: Get Route URL |
|||
command: oc get route {{ itix_sso_application_name }} -n "{{ itix_sso_project }}" -o 'jsonpath={.spec.host}' |
|||
register: route |
|||
changed_when: false |
|||
tags: status |
|||
|
|||
- set_fact: |
|||
sso_route_name: '{{ route.stdout }}' |
|||
|
|||
- name: SSO is ready ! |
|||
debug: msg="Login on https://{{ sso_route_name }}/auth/admin with username = '{{ username.stdout }}' and password = '{{ password.stdout }}'" |
|||
tags: status |
|||
Loading…
Reference in new issue