diff --git a/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml b/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml index d7124764..e88e44e5 100644 --- a/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml +++ b/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml @@ -74,6 +74,81 @@ spec: - kind: AWX name: awxs.awx.ansible.com version: v1beta1 + description: A AWX Instance + specDescriptors: + - displayName: Hostname + path: tower_hostname + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:text + - displayName: Admin email address + path: tower_admin_email + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:text + - displayName: Admin password secret + path: tower_admin_password_secret + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:io.kubernetes:Secret + - displayName: Database configuration secret + path: tower_postgres_configuration_secret + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:io.kubernetes:Secret + - displayName: Secret key secret + path: tower_secret_key_secret + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:io.kubernetes:Secret + - displayName: Ingress Type + path: tower_ingress_type + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:select:none + - urn:alm:descriptor:com.tectonic.ui:select:Ingress + - urn:alm:descriptor:com.tectonic.ui:select:Route + - displayName: Image Pull Policy + path: tower_image_pull_policy + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:imagePullPolicy + - displayName: Replicas + path: tower_replicas + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:number + - displayName: Remove used secrets on instance removal ? + path: tower_garbage_collect_secrets + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:boolean + - displayName: Preload instance with data upon creation ? + path: tower_create_preload_data + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:boolean + statusDescriptors: + - displayName: URL + description: Route to access the instance deployed + path: towerURL + x-descriptors: + - urn:alm:descriptor:org.w3:link + - displayName: Admin User + description: Admin user for the instance deployed + path: towerAdminUser + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:label + - displayName: Admin Password + description: Admin password for the instance deployed + path: towerAdminPasswordSecret + x-descriptors: + - urn:alm:descriptor:io.kubernetes:Secret + - displayName: Version + description: Version of the instance deployed + path: towerVersion + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:label description: AWX operator displayName: AWX icon: diff --git a/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxs_crd.yaml b/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxs_crd.yaml index 6098bc76..154c8890 100644 --- a/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxs_crd.yaml +++ b/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxs_crd.yaml @@ -20,7 +20,60 @@ spec: properties: spec: properties: + tower_hostname: + description: The hostname of the instance + type: string + tower_admin_email: + description: The admin user email + type: string + tower_admin_password_secret: + description: Secret where the admin password can be found + type: string + tower_postgres_configuration_secret: + description: Secret where the database configuration can be found + type: string + tower_secret_key_secret: + description: Secret where the secret key can be found + type: string + tower_ingress_type: + description: The ingress type to use to reach the deployed instance + type: string + enum: + - none + - Ingress + - Route + tower_image_pull_policy: + description: The image pull policy + type: string + enum: + - Always + - Never + - IfNotPresent + tower_replicas: + description: Number of instance replicas + type: integer + format: int32 + tower_garbage_collect_secrets: + description: Whether or not to remove secrets upon instance removal + type: boolean + tower_create_preload_data: + description: Whether or not to preload data upon Tower instance creation + type: boolean type: object + status: + properties: + towerURL: + description: URL to access the deployed instance + type: string + towerAdminUser: + description: Admin user of the deployed instance + type: string + towerAdminPasswordSecret: + description: Admin password of the deployed instance + type: string + towerVersion: + description: Version of the deployed instance + type: string type: object version: v1beta1 versions: diff --git a/roles/installer/tasks/admin_password_configuration.yml b/roles/installer/tasks/admin_password_configuration.yml index 2fec994e..9f58e966 100644 --- a/roles/installer/tasks/admin_password_configuration.yml +++ b/roles/installer/tasks/admin_password_configuration.yml @@ -40,12 +40,3 @@ - name: Store admin password set_fact: tower_admin_password: "{{ admin_password_secret['resources'][0]['data']['password'] | b64decode }}" - -- name: Set admin password secret status - operator_sdk.util.k8s_status: - api_version: awx.ansible.com/v1beta1 - kind: "{{ deployment_type | upper }}" - name: "{{ meta.name }}" - namespace: "{{ meta.namespace }}" - status: - towerAdminPasswordSecret: "{{ admin_password_secret['resources'][0]['metadata']['name'] }}" diff --git a/roles/installer/tasks/main.yml b/roles/installer/tasks/main.yml index be3beeef..473f57b3 100644 --- a/roles/installer/tasks/main.yml +++ b/roles/installer/tasks/main.yml @@ -68,3 +68,6 @@ when: (k8s_defs_result is changed) or (database_check is defined and database_check.return_code != 0) - include_tasks: initialize.yml + +- name: Update status variables + include_tasks: update_status.yml diff --git a/roles/installer/tasks/update_status.yml b/roles/installer/tasks/update_status.yml new file mode 100644 index 00000000..267d45c2 --- /dev/null +++ b/roles/installer/tasks/update_status.yml @@ -0,0 +1,56 @@ +--- +- name: Update admin password status + operator_sdk.util.k8s_status: + api_version: awx.ansible.com/v1beta1 + kind: "{{ deployment_type | upper }}" + name: "{{ meta.name }}" + namespace: "{{ meta.namespace }}" + status: + towerAdminPasswordSecret: "{{ admin_password_secret['resources'][0]['metadata']['name'] }}" + +- name: Update admin user status + operator_sdk.util.k8s_status: + api_version: awx.ansible.com/v1beta1 + kind: "{{ deployment_type | upper }}" + name: "{{ meta.name }}" + namespace: "{{ meta.namespace }}" + status: + towerAdminUser: "{{ tower_admin_user }}" + +- name: Retrieve instance version + community.kubernetes.k8s_exec: + namespace: "{{ meta.namespace }}" + pod: "{{ tower_pod_name }}" + container: "{{ meta.name }}-task" + command: >- + bash -c "awx-manage --version" + register: instance_version + changed_when: false + +- name: Update version status + operator_sdk.util.k8s_status: + api_version: awx.ansible.com/v1beta1 + kind: "{{ deployment_type | upper }}" + name: "{{ meta.name }}" + namespace: "{{ meta.namespace }}" + status: + towerVersion: "{{ instance_version.stdout }}" + +- block: + - name: Retrieve route URL + community.kubernetes.k8s_info: + kind: Route + namespace: '{{ meta.namespace }}' + name: '{{ meta.name }}' + register: route_url + + - name: Update URL status + operator_sdk.util.k8s_status: + api_version: awx.ansible.com/v1beta1 + kind: "{{ deployment_type | upper }}" + name: "{{ meta.name }}" + namespace: "{{ meta.namespace }}" + status: + towerURL: "https://{{ route_url['resources'][0]['status']['ingress'][0]['host'] }}" + + when: tower_ingress_type | lower == 'route'