Update CSV with richer fields

This commit is contained in:
Yanis Guenane
2021-02-02 13:17:31 +01:00
parent 821198c05e
commit 452bb128c6
5 changed files with 187 additions and 9 deletions

View File

@@ -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:

View File

@@ -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:

View File

@@ -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'] }}"

View File

@@ -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

View File

@@ -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'