mirror of
https://github.com/ansible/awx.git
synced 2026-02-02 18:18:12 -03:30
`oc new-app --template=postgresql-persistent` has been kind of a pain. It would attempt to create a Persistent Volume, but does not allow you to specify the storageClass. This code assumes that a Persistent Volume is already available and will fail with a helpful error message if it is not. Signed-off-by: Shane McDonald <me@shanemcd.com>
61 lines
2.0 KiB
YAML
61 lines
2.0 KiB
YAML
---
|
|
- include_vars: openshift.yml
|
|
|
|
- name: Ensure workspace directories exist
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
with_items:
|
|
- "{{ kubernetes_base_path }}"
|
|
- "{{ openshift_oc_config_file | dirname }}"
|
|
|
|
- name: Authenticate with OpenShift via user and password
|
|
shell: |
|
|
{{ openshift_oc_bin }} login {{ openshift_host }} \
|
|
-u {{ openshift_user }} \
|
|
-p {{ openshift_password }} \
|
|
--insecure-skip-tls-verify={{ openshift_skip_tls_verify | default(false) | bool }}
|
|
when:
|
|
- openshift_user is defined
|
|
- openshift_password is defined
|
|
- openshift_token is not defined
|
|
no_log: true
|
|
|
|
- name: Authenticate with OpenShift via token
|
|
shell: |
|
|
{{ openshift_oc_bin }} login {{ openshift_host }} \
|
|
--token {{ openshift_token }} \
|
|
--insecure-skip-tls-verify={{ openshift_skip_tls_verify | default(false) | bool }}
|
|
when: openshift_token is defined
|
|
no_log: true
|
|
|
|
- name: Get Project Detail
|
|
shell: "{{ openshift_oc_bin }} get project {{ awx_openshift_project }}"
|
|
register: project_details
|
|
ignore_errors: yes
|
|
|
|
- name: Create AWX Openshift Project
|
|
shell: "{{ openshift_oc_bin }} new-project {{ awx_openshift_project }}"
|
|
when: project_details.rc != 0
|
|
|
|
- name: Ensure PostgreSQL PVC is available
|
|
block:
|
|
- name: Check PVC status
|
|
command: "{{ openshift_oc_bin }} get pvc {{ openshift_pg_pvc_name }} -n {{ awx_openshift_project }} -o=jsonpath='{.status.phase}'"
|
|
register: pg_pvc_status
|
|
ignore_errors: yes
|
|
|
|
- name: Ensure PostgreSQL PVC is available
|
|
assert:
|
|
that:
|
|
- pg_pvc_status.stdout == "Bound"
|
|
msg: "Ensure a PVC named '{{ openshift_pg_pvc_name }}' is created and bound in the '{{ awx_openshift_project }}' namespace."
|
|
when:
|
|
- pg_hostname is not defined or pg_hostname == ''
|
|
- openshift_pg_emptydir is defined and openshift_pg_emptydir != true
|
|
|
|
- name: Set postgresql service name
|
|
set_fact:
|
|
postgresql_service_name: "postgresql"
|
|
when: "pg_hostname is not defined or pg_hostname == ''"
|