From 21eb83b0525eb42db78cf9daaf9eca3a975e1715 Mon Sep 17 00:00:00 2001 From: David Hageman Date: Wed, 11 Jan 2023 10:41:35 -0600 Subject: [PATCH] Correct admin password updating (#1179) Corrects an issue with admin passwords failing to be updated due to shell escaping. This aligns the operator with the logic in the normal installer. --- roles/installer/tasks/initialize_django.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/roles/installer/tasks/initialize_django.yml b/roles/installer/tasks/initialize_django.yml index 057c1a392..bc75a06ab 100644 --- a/roles/installer/tasks/initialize_django.yml +++ b/roles/installer/tasks/initialize_django.yml @@ -18,10 +18,21 @@ namespace: "{{ ansible_operator_meta.namespace }}" pod: "{{ tower_pod_name }}" container: "{{ ansible_operator_meta.name }}-task" - command: >- - bash -c "echo \"from django.contrib.auth.models import User; - User.objects.create_superuser('{{ admin_user }}', '{{ admin_email }}', '{{ admin_password }}')\" - | awx-manage shell" + command: awx-manage createsuperuser --username={{ admin_user | quote }} --email={{ admin_email | quote }} --noinput + register: result + changed_when: "'That username is already taken' not in result.stderr" + failed_when: "'That username is already taken' not in result.stderr and 'Superuser created successfully' not in result.stdout" + no_log: "{{ no_log }}" + when: users_result.return_code > 0 + +- name: Update Django super user password + k8s_exec: + namespace: "{{ ansible_operator_meta.namespace }}" + pod: "{{ tower_pod_name }}" + container: "{{ ansible_operator_meta.name }}-task" + command: awx-manage update_password --username='{{ admin_user }}' --password='{{ admin_password }}' + register: result + changed_when: "'Password updated' in result.stdout" no_log: "{{ no_log }}" when: users_result.return_code > 0