mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
more robustness
This commit is contained in:
parent
190525e835
commit
7d24566120
@ -1,34 +1,70 @@
|
||||
---
|
||||
- name: Apply admin user addon
|
||||
shell: minishift addon apply admin-user
|
||||
- name: Get status of minishift
|
||||
shell: minishift status
|
||||
register: minishift_status
|
||||
|
||||
- name: Echo minishift status so if verification fails we can see the results
|
||||
debug:
|
||||
var: minishift_status.stdout
|
||||
|
||||
- name: Verify status of minishift
|
||||
assert:
|
||||
that:
|
||||
- "'Minishift: Running' == minishift_status.stdout_lines[0]"
|
||||
- "'OpenShift: Running' in minishift_status.stdout_lines[2]"
|
||||
|
||||
- name: Get minishift ip
|
||||
shell: minishift ip
|
||||
register: minishift_ip
|
||||
|
||||
- name: Get minishift oc location
|
||||
shell: minishift oc-env
|
||||
register: minishift_oc_env
|
||||
|
||||
- name: Extract minishift binary path
|
||||
set_fact:
|
||||
minishift_oc_bin: "{{ minishift_oc_env.stdout_lines[0] | regex_replace('export PATH=\\\"(.*):\\$PATH\\\"', '\\1') }}/oc"
|
||||
|
||||
- name: Dynamically found oc binary to be at
|
||||
debug:
|
||||
msg: "oc path: {{ minishift_oc_bin }}"
|
||||
|
||||
- name: Login as admin
|
||||
shell: "{{ minishift_oc_bin }} login {{ minishift_ip.stdout }}:8443 -u system:admin"
|
||||
|
||||
- name: Create privileged user service account awx
|
||||
shell: "{{ minishift_oc_bin }} adm policy add-scc-to-user privileged system:serviceaccount:{{ awx_dev_project }}:awx"
|
||||
|
||||
- name: Authenticate with OpenShift via token
|
||||
shell: "{{ minishift_oc_bin }} login {{ minishift_ip.stdout }}:8443 -u admin -p admin"
|
||||
|
||||
- name: Unattach AWX dev tree volume locally
|
||||
shell: "minishift hostfolder remove awx || true"
|
||||
|
||||
- name: Attach AWX dev tree volume locally
|
||||
shell: "minishift hostfolder add -t sshfs --source {{ devtree_directory }} --target /mnt/sda1/awx awx"
|
||||
register: hostfolderadd
|
||||
ignore_errors: yes
|
||||
shell: "minishift hostfolder add -t sshfs --source {{ devtree_directory }} --target /mnt/sda1/awx awx"
|
||||
|
||||
- name: Fail if hostfolder add issue was something other than already attached
|
||||
fail: msg="There was an issue attaching hostfolder '{{ hostfolderadd.stdout }}' '{{ hostfolderadd.stderr }}'"
|
||||
when: hostfolderadd.rc != 0 and "there is already a host folder" not in hostfolderadd.stderr
|
||||
- name: Unmount AWX dev volume
|
||||
shell: "minishift hostfolder umount awx || true"
|
||||
|
||||
- name: Mount AWX dev volume
|
||||
shell: minishift hostfolder mount awx
|
||||
|
||||
- name: Authenticate with OpenShift via token
|
||||
shell: "oc login -u admin -p admin"
|
||||
shell: "{{ minishift_oc_bin }} login -u admin -p admin"
|
||||
|
||||
- name: Get Project Detail
|
||||
shell: "oc get project {{ awx_dev_project }}"
|
||||
shell: "{{ minishift_oc_bin }} get project {{ awx_dev_project }}"
|
||||
register: project_details
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Get Postgres Service Detail
|
||||
shell: "oc describe svc postgresql -n {{ awx_dev_project }}"
|
||||
shell: "{{ minishift_oc_bin }} describe svc postgresql -n {{ awx_dev_project }}"
|
||||
register: postgres_svc_details
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Create AWX Openshift Project
|
||||
shell: "oc new-project {{ awx_dev_project }}"
|
||||
shell: "{{ minishift_oc_bin }} new-project {{ awx_dev_project }}"
|
||||
when: project_details.rc != 0
|
||||
|
||||
- name: Stage serviceacct.yml
|
||||
@ -37,7 +73,7 @@
|
||||
dest: /tmp/serviceacct.yml
|
||||
|
||||
- name: Apply svc account
|
||||
shell: "oc apply -f /tmp/serviceacct.yml ; rm -rf /tmp/serviceaccount.yml"
|
||||
shell: "{{ minishift_oc_bin }} apply -f /tmp/serviceacct.yml ; rm -rf /tmp/serviceaccount.yml"
|
||||
|
||||
- name: Stage hostfolderpvc.yml
|
||||
template:
|
||||
@ -45,7 +81,7 @@
|
||||
dest: /tmp/hostfolderpvc.yml
|
||||
|
||||
- name: Create PV for host folder
|
||||
shell: "oc apply -f /tmp/hostfolderpvc.yml ; rm -rf /tmp/hostfolderpvc.yml"
|
||||
shell: "{{ minishift_oc_bin }} apply -f /tmp/hostfolderpvc.yml ; rm -rf /tmp/hostfolderpvc.yml"
|
||||
|
||||
- name: Stage volumeclaim.yml
|
||||
template:
|
||||
@ -55,11 +91,8 @@
|
||||
- name: Create PV for host folder
|
||||
shell: "oc apply -f /tmp/volumeclaim.yml ; rm -rf /tmp/volumeclaim.yml"
|
||||
|
||||
- name: Create privileged user service account awx
|
||||
shell: "oc adm policy add-scc-to-user privileged system:serviceaccount:{{ awx_dev_project }}:awx"
|
||||
|
||||
- name: Deploy and Activate Postgres
|
||||
shell: "oc new-app --template=postgresql-persistent -e MEMORY_LIMIT={{ pg_memory_limit|default('512') }}Mi -e NAMESPACE=openshift -e DATABASE_SERVICE_NAME=postgresql -e POSTGRESQL_USER={{ pg_username|default('awx') }} -e POSTGRESQL_PASSWORD={{ pg_password|default('awx') }} -e POSTGRESQL_DATABASE={{ pg_database|default('awx') }} -e VOLUME_CAPACITY={{ pg_volume_capacity|default('5')}}Gi -e POSTGRESQL_VERSION=9.5 -n {{ awx_dev_project }}"
|
||||
shell: "{{ minishift_oc_bin }} new-app --template=postgresql-persistent -e MEMORY_LIMIT={{ pg_memory_limit|default('512') }}Mi -e NAMESPACE=openshift -e DATABASE_SERVICE_NAME=postgresql -e POSTGRESQL_USER={{ pg_username|default('awx') }} -e POSTGRESQL_PASSWORD={{ pg_password|default('awx') }} -e POSTGRESQL_DATABASE={{ pg_database|default('awx') }} -e VOLUME_CAPACITY={{ pg_volume_capacity|default('5')}}Gi -e POSTGRESQL_VERSION=9.5 -n {{ awx_dev_project }}"
|
||||
when: postgres_svc_details is defined and postgres_svc_details.rc != 0
|
||||
register: openshift_pg_activate
|
||||
|
||||
@ -74,7 +107,7 @@
|
||||
dest: "/tmp/configmap.yml"
|
||||
|
||||
- name: Create configmap
|
||||
shell: "oc apply -f /tmp/configmap.yml ; rm -rf /tmp/configmap.yml"
|
||||
shell: "{{ minishift_oc_bin }} apply -f /tmp/configmap.yml ; rm -rf /tmp/configmap.yml"
|
||||
|
||||
- name: Template deployment
|
||||
template:
|
||||
@ -82,4 +115,8 @@
|
||||
dest: "/tmp/hostdev.yml"
|
||||
|
||||
- name: Create deployment
|
||||
shell: "oc apply -f /tmp/hostdev.yml ; rm -rf /tmp/hostdev.yml"
|
||||
shell: "{{ minishift_oc_bin }} apply -f /tmp/hostdev.yml ; rm -rf /tmp/hostdev.yml"
|
||||
|
||||
- name: Please login
|
||||
debug:
|
||||
msg: "Login at https://{{ minishift_ip.stdout }}:8443 with admin / admin"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user