Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 7 additions & 40 deletions playbooks/aap_get_admin_credentials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,14 @@
gather_facts: false
vars:
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
# Public overrides — keep aap_* names so existing callers do not regress
aap_namespace: ansible-automation-platform
aap_route_name: aap
aap_secret_name: aap-admin-password
admin_cred_label: AAP
admin_cred_namespace: "{{ aap_namespace }}"
admin_cred_route_name: "{{ aap_route_name }}"
admin_cred_secret_name: "{{ aap_secret_name }}"
tasks:
- name: Retrieve API hostname for AAP
kubernetes.core.k8s_info:
api_version: route.openshift.io/v1
kind: Route
namespace: "{{ aap_namespace }}"
name: "{{ aap_route_name }}"
register: aap_host
until: aap_host.resources | length == 1
retries: 20
delay: 5

- name: Set ansible_host
ansible.builtin.set_fact:
ansible_host: "{{ aap_host.resources[0].spec.host }}"

- name: Retrieve admin password for AAP
kubernetes.core.k8s_info:
kind: Secret
namespace: "{{ aap_namespace }}"
name: "{{ aap_secret_name }}"
register: admin_pw
until: admin_pw.resources | length == 1
retries: 20
delay: 5

- name: Set admin_password fact
ansible.builtin.set_fact:
admin_password: "{{ admin_pw.resources[0].data.password | b64decode }}"

- name: Report AAP Endpoint
ansible.builtin.debug:
msg: "AAP Endpoint: https://{{ ansible_host }}"

- name: Report AAP User
ansible.builtin.debug:
msg: "AAP Admin User: admin"

- name: Report AAP Admin Password
ansible.builtin.debug:
msg: "AAP Admin Password: {{ admin_password }}"
- name: Retrieve and display AAP admin credentials
ansible.builtin.include_tasks: tasks/aap_ao_get_admin_credentials.yml
19 changes: 19 additions & 0 deletions playbooks/ao_get_admin_credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Retrieve Credentials for AO on OpenShift
become: false
connection: local
hosts: localhost
gather_facts: false
vars:
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
# Public overrides — keep ao_* names so existing callers do not regress
ao_namespace: automation-orchestrator
ao_route_name: orchestrator
ao_secret_name: orchestrator-initial-admin-password
admin_cred_label: AO
admin_cred_namespace: "{{ ao_namespace }}"
admin_cred_route_name: "{{ ao_route_name }}"
admin_cred_secret_name: "{{ ao_secret_name }}"
tasks:
- name: Retrieve and display AO admin credentials
ansible.builtin.include_tasks: tasks/aap_ao_get_admin_credentials.yml
52 changes: 52 additions & 0 deletions playbooks/tasks/aap_ao_get_admin_credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# Shared workflow to retrieve an OpenShift route hostname and admin password secret,
# then display endpoint/user/password.
#
# Expected variables:
# admin_cred_label: Product label used in debug messages (e.g. AAP, AO)
# admin_cred_namespace: Namespace containing the Route and Secret
# admin_cred_route_name: Name of the Route resource
# admin_cred_secret_name: Name of the Secret containing the admin password
# Optional:
# admin_cred_user: Admin username to report (default: admin)
# admin_cred_secret_key: Secret data key for the password (default: password)
- name: Retrieve API hostname for {{ admin_cred_label }}
kubernetes.core.k8s_info:
api_version: route.openshift.io/v1
kind: Route
namespace: "{{ admin_cred_namespace }}"
name: "{{ admin_cred_route_name }}"
register: admin_cred_route
until: admin_cred_route.resources | length == 1
retries: 20
delay: 5

- name: Set ansible_host
ansible.builtin.set_fact:
ansible_host: "{{ admin_cred_route.resources[0].spec.host }}"

- name: Retrieve admin password for {{ admin_cred_label }}
kubernetes.core.k8s_info:
kind: Secret
namespace: "{{ admin_cred_namespace }}"
name: "{{ admin_cred_secret_name }}"
register: admin_pw
until: admin_pw.resources | length == 1
retries: 20
delay: 5

- name: Set admin_password fact
ansible.builtin.set_fact:
admin_password: "{{ admin_pw.resources[0].data[admin_cred_secret_key | default('password')] | b64decode }}"

- name: Report {{ admin_cred_label }} Endpoint
ansible.builtin.debug:
msg: "{{ admin_cred_label }} Endpoint: https://{{ ansible_host }}"

- name: Report {{ admin_cred_label }} User
ansible.builtin.debug:
msg: "{{ admin_cred_label }} Admin User: {{ admin_cred_user | default('admin') }}"

- name: Report {{ admin_cred_label }} Admin Password
ansible.builtin.debug:
msg: "{{ admin_cred_label }} Admin Password: {{ admin_password }}"
Loading