Need to be specific on the container we call the commands on

This commit is contained in:
Matthew Jones
2020-05-29 16:58:41 -04:00
parent 02efdee863
commit 88db86ad9e
2 changed files with 5 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
---
- name: Check if there are any Tower super users defined.
shell: >-
kubectl exec -n {{ meta.namespace }} {{ tower_pod_name }} -- bash -c
kubectl exec -n {{ meta.namespace }} -c tower-task {{ tower_pod_name }} -- bash -c
"echo 'from django.contrib.auth.models import User;
nsu = User.objects.filter(is_superuser=True).count();
exit(0 if nsu > 0 else 1)'
@@ -12,7 +12,7 @@
- name: Create Tower super user via Django if it doesn't exist.
shell: >-
kubectl exec -n {{ meta.namespace }} {{ tower_pod_name }} -- bash -c
kubectl exec -n {{ meta.namespace }} -c tower-task {{ tower_pod_name }} -- bash -c
"echo \"from django.contrib.auth.models import User;
User.objects.create_superuser('{{ tower_admin_user }}', '{{ tower_admin_email }}', '{{ tower_admin_password }}')\"
| awx-manage shell"
@@ -21,7 +21,7 @@
- name: Create preload data if necessary. # noqa 305
shell: >-
kubectl exec -n {{ meta.namespace }} {{ tower_pod_name }} -- bash -c
kubectl exec -n {{ meta.namespace }} -c tower-task {{ tower_pod_name }} -- bash -c
"awx-manage create_preload_data"
register: cdo
changed_when: "'added' in cdo.stdout"

View File

@@ -34,7 +34,7 @@
- name: Check if database is populated (auth_user table exists).
shell: >-
kubectl exec -n {{ meta.namespace }} {{ tower_pod_name }} -- bash -c
kubectl exec -n {{ meta.namespace }} -c tower-task {{ tower_pod_name }} -- bash -c
"echo 'from django.db import connection;
tbl = \"auth_user\" in connection.introspection.table_names();
exit(0 if tbl else 1)'
@@ -46,7 +46,7 @@
- name: Migrate the database if the K8s resources were updated. # noqa 305
shell: >-
kubectl exec -n {{ meta.namespace }} {{ tower_pod_name }} -- bash -c
kubectl exec -n {{ meta.namespace }} -c tower-task {{ tower_pod_name }} -- bash -c
"awx-manage migrate --noinput"
register: migrate_result
when: (k8s_defs_result is changed) or (database_check is defined and database_check.rc != 0)