diff --git a/playbooks/deploy-xch.yml b/playbooks/deploy-xch.yml new file mode 100644 index 0000000..495861b --- /dev/null +++ b/playbooks/deploy-xch.yml @@ -0,0 +1,9 @@ +--- + +- name: Deploy the exchanger application + hosts: itix + become: yes + vars: + itix_xch_route: xch.{{ openshift_master_default_subdomain }} + roles: + - { name: 'xch', tags: 'xch' } diff --git a/playbooks/site.yml b/playbooks/site.yml index defebc7..5eeab4f 100644 --- a/playbooks/site.yml +++ b/playbooks/site.yml @@ -17,3 +17,5 @@ - include: "deploy-prometheus.yml" - include: "configure-openshift-access-control.yml" + + - include: "deploy-xch.yml" diff --git a/roles/xch/defaults/main.yml b/roles/xch/defaults/main.yml new file mode 100644 index 0000000..e2753cc --- /dev/null +++ b/roles/xch/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +itix_xch_project: xch +itix_xch_template: minio +itix_xch_retries: 30 +itix_xch_delay: 5 diff --git a/roles/xch/tasks/main.yml b/roles/xch/tasks/main.yml new file mode 100644 index 0000000..d643e81 --- /dev/null +++ b/roles/xch/tasks/main.yml @@ -0,0 +1,63 @@ +--- + +- 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 Minio + command: oc new-project "{{ itix_xch_project }}" + when: '"projects/" ~ itix_xch_project not in oc_get_projects.stdout_lines' + +- name: Query existing deploymentconfigs + command: oc get dc -n "{{ itix_xch_project }}" -o name -l "app=minio" + register: oc_get_dc + changed_when: false + +- name: Deploy app if needed + set_fact: + deploy_needed: "{{ 'deploymentconfigs/minio' not in oc_get_dc.stdout_lines }}" + +- name: Process the OpenShift Template and create the OpenShift objects + command: oc new-app -n {{ itix_xch_project }} {{ itix_xch_template }} -p "MINIO_ROUTE_HOSTNAME={{ itix_xch_hostname }}" + when: deploy_needed + +- name: Wait for OpenShift to create all objects + pause: + seconds: '{{ itix_xch_delay }}' + when: deploy_needed + +- include: common/wait_for.yml + static: no + vars: + pod_to_wait: + - minio + delay: "{{ itix_xch_delay }}" + retries: "{{ itix_xch_retries }}" + project: "{{ itix_xch_project }}" + tags: status + +- name: Get Admin Username + command: oc get dc minio -n "{{ itix_xch_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="MINIO_ACCESS_KEY")].value}' + register: username + changed_when: false + tags: status + +- name: Get Admin Password + command: oc get dc minio -n "{{ itix_xch_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="MINIO_SECRET_KEY")].value}' + register: password + changed_when: false + tags: status + +- name: Get Route URL + command: oc get route minio -n "{{ itix_xch_project }}" -o 'jsonpath={.spec.host}' + register: route + changed_when: false + tags: status + +- set_fact: + xch_route_name: '{{ route.stdout }}' + +- name: Minio is ready ! + debug: msg="Login on https://{{ xch_route_name }}/ with username = '{{ username.stdout }}' and password = '{{ password.stdout }}'" + tags: status