--- - name: Configure AAP hosts: localhost vars: - aap2_automationactrl_url: https://automation-aap.apps.hub.5g-deployment.lab - aap2_webconsole_user: admin - hub_kubeconfig_path: /root/.kcli/clusters/hub/auth/kubeconfig - repo_user: RHsyseng - lab_version: lab-4.14 - lab_registry_host: "infra.5g-deployment.lab:8443" tasks: - name: Wait for AAP Controller to come up delegate_to: localhost ansible.builtin.uri: url: "{{ aap2_automationactrl_url }}/api/v2/ping/" status_code: 200 validate_certs: false register: result until: - result.json is defined - result.json.instances[0].heartbeat is defined - result.json.instances[0].node_type == "control" retries: 10 delay: 30 ignore_errors: true - name: Get AutomationController admin password kubernetes.core.k8s_info: kubeconfig: "{{ hub_kubeconfig_path }}" api_version: v1 kind: Secret name: automation-admin-password namespace: aap register: aap_automationctrlpwd retries: 20 delay: 10 until: - aap_automationctrlpwd is defined - aap_automationctrlpwd.resources | length > 0 - aap_automationctrlpwd.resources[0].data is defined - aap_automationctrlpwd.resources[0].data.password is defined - name: Ensure Controller License is loaded ansible.builtin.include_role: name: infra.controller_configuration.license apply: delegate_to: localhost vars: controller_license: manifest_file: "{{ aap_manifest_file_path }}" controller_validate_certs: false controller_hostname: "{{ aap2_automationactrl_url }}" controller_username: "{{ aap2_webconsole_user }}" controller_password: "{{ aap_automationctrlpwd.resources[0].data.password | ansible.builtin.b64decode }}" - name: Ensure folder for AutomationController configs exists delegate_to: localhost ansible.builtin.file: path: /tmp/aap2configs/{{ item }} state: directory mode: 0755 with_items: - "Lab" - "Lab/credentials" - "Lab/inventories" - "Lab/inventories/Lab Inventory" - "Lab/inventories/ZTP Done Clusters" - "Lab/job_templates" - "Lab/projects" - "Lab/users" - "user_roles" - name: Ensure AutomationController configs are downloaded delegate_to: localhost ansible.builtin.get_url: url: "{{ item.url }}" dest: "{{ item.destination }}" mode: "{{ item.mode }}" retries: 5 delay: 10 with_items: - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/current_credential_types.yaml", destination: "/tmp/aap2configs/", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/current_execution_environments.yaml", destination: "/tmp/aap2configs/", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/user_roles/current_roles_student.yaml", destination: "/tmp/aap2configs/user_roles", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/current_organization.yaml", destination: "/tmp/aap2configs/Lab/", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/users/student.yaml", destination: "/tmp/aap2configs/Lab/users/student.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/projects/8_5G%20RAN%20Lab%20Project.yaml", destination: "/tmp/aap2configs/Lab/projects/8_5G RAN Lab Project.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/job_templates/10_ZTP%20Done%20Automation.yaml", destination: "/tmp/aap2configs/Lab/job_templates/10_ZTP Done Automation.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/inventories/Lab%20Inventory/2_Lab%20Inventory.yaml", destination: "/tmp/aap2configs/Lab/inventories/Lab Inventory/2_Lab Inventory.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/inventories/Lab%20Inventory/current_inventory_sources.yaml", destination: "/tmp/aap2configs/Lab/inventories/Lab Inventory/current_inventory_sources.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/inventories/ZTP%20Done%20Clusters/3_ZTP%20Done%20Clusters.yaml", destination: "/tmp/aap2configs/Lab/inventories/ZTP Done Clusters/3_ZTP Done Clusters.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/inventories/ZTP%20Done%20Clusters/current_inventory_sources.yaml", destination: "/tmp/aap2configs/Lab/inventories/ZTP Done Clusters/current_inventory_sources.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/credentials/3_Gitea%20Credentials.yaml", destination: "/tmp/aap2configs/Lab/credentials/3_Gitea Credentials.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/credentials/6_HUB%20Cluster%20Kubeconfig.yaml", destination: "/tmp/aap2configs/Lab/credentials/6_HUB Cluster Kubeconfig.yaml", mode: "0644"} - {url: "https://raw.githubusercontent.com/{{ repo_user }}/5g-ran-deployments-on-ocp-lab/{{ lab_version }}/lab-materials/lab-env-data/aap2/config-files/Lab/credentials/8_Lab%20Disconnected%20Registry.yaml", destination: "/tmp/aap2configs/Lab/credentials/8_Lab Disconnected Registry.yaml", mode: "0644"} - name: Read Hub Kubeconfig file delegate_to: localhost ansible.builtin.slurp: src: "{{ hub_kubeconfig_path }}" register: hub_kubeconfig_file - name: Ensure Controller configs are read ansible.builtin.include_role: name: infra.controller_configuration.filetree_read apply: delegate_to: localhost vars: filetree_controller_settings: "/tmp/aap2configs" filetree_controller_organizations: "/tmp/aap2configs" filetree_controller_labels: "/tmp/aap2configs" filetree_controller_user_accounts: "/tmp/aap2configs" filetree_controller_teams: "/tmp/aap2configs" filetree_controller_credential_types: "/tmp/aap2configs" filetree_controller_credentials: "/tmp/aap2configs" filetree_controller_credential_input_sources: "/tmp/aap2configs" filetree_controller_notifications: "/tmp/aap2configs" filetree_controller_projects: "/tmp/aap2configs" filetree_controller_execution_environments: "/tmp/aap2configs" filetree_controller_applications: "/tmp/aap2configs" filetree_controller_inventories: "/tmp/aap2configs" filetree_controller_inventory_sources: "/tmp/aap2configs" filetree_controller_instance_groups: "/tmp/aap2configs" filetree_controller_hosts: "/tmp/aap2configs" filetree_controller_groups: "/tmp/aap2configs" filetree_controller_templates: "/tmp/aap2configs" filetree_controller_workflow_job_templates: "/tmp/aap2configs" filetree_controller_schedules: "/tmp/aap2configs" filetree_controller_roles: "/tmp/aap2configs" gitea_user: "student" gitea_pwd: "student" hub_kubeconfig_file_content: "{{ hub_kubeconfig_file.content | b64decode }}" disconnected_registry_host: "{{ lab_registry_host }}" disconnected_registry_user: "admin" disconnected_registry_pwd: "r3dh4t1!" inventory_source_path: "inventories/cluster-inventory-example.yml" playbook_source_path: "playbooks/cluster_mgmt_example_playbook.yml" aap_repository_url: "http://infra.5g-deployment.lab:3000/student/aap-integration-tools.git" student_aap_pwd: "{{ strong_student_password }}" execution_environment_img: "infra.5g-deployment.lab:8443/rhsysdeseng/5granlab-ee:lab" controller_validate_certs: false controller_hostname: "{{ aap2_automationactrl_url }}" controller_username: "{{ aap2_webconsole_user }}" controller_password: "{{ aap_automationctrlpwd.resources[0].data.password | ansible.builtin.b64decode }}" - name: Ensure AAP Controller is up delegate_to: localhost ansible.builtin.uri: url: "{{ aap2_automationactrl_url }}/api/v2/ping/" status_code: 200 validate_certs: false register: result until: - result.json is defined - result.json.instances[0].heartbeat is defined - result.json.instances[0].node_type == "control" retries: 10 delay: 30 ignore_errors: true # Until the controller_configuration dispatch collection gets updated to properly manage # constructed inventories we need to run multiples times the role. - name: Ensure Controller configs are loaded ansible.builtin.include_role: name: infra.controller_configuration.dispatch apply: delegate_to: localhost ignore_errors: "{{ item }}" vars: controller_configuration_projects_async_retries: 120 controller_configuration_projects_async_delay: 2 controller_validate_certs: false controller_configuration_async_dir: "/tmp" controller_hostname: "{{ aap2_automationactrl_url }}" controller_username: "{{ aap2_webconsole_user }}" controller_password: "{{ aap_automationctrlpwd.resources[0].data.password | ansible.builtin.b64decode }}" with_items: - true - true - true - true - false - name: Ensure AutomationController admin password is deleted delegate_to: localhost kubernetes.core.k8s: kubeconfig: "{{ hub_kubeconfig_path }}" api_version: v1 kind: Secret name: automation-admin-password namespace: aap state: absent retries: 20 delay: 10