ansible / awx-resource-operator

41 stars 31 forks source link

Add Support For Inventory Kind, Variables in Ansible Inventories #137

Closed neevnuv closed 6 months ago

neevnuv commented 9 months ago

Ansible Inventory CRD only allows defining:

As of now we cannot create an inventory that contain inventory kind and variables. I propose we add properties for all those properties to the CRD.

neevnuv commented 9 months ago

Maybe their properties should be defined in the AnsibleInventory CRD like this:

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: ansibleinventories.tower.ansible.com
spec:
  versions:
  - name: v1alpha1
    schema:
      openAPIV3Schema:
        description: Inventory is the Schema for the inventories API
        properties:
          apiVersion:
            type: string
          kind:
            type: string
          metadata:
            type: object
          spec:
            properties:
                kind:
                  type: string
                  default: ""
                  enum: ["", "smart", "constructed"]
                  description: Kind defines the desired kind of inventory; inventory, smart inventory or constructed inventory
                variables:
                  type: object
                  description: Variables defines the desired variables you add to your inventory
            description: Spec defines the desired state of Inventory
            type: object
            x-kubernetes-preserve-unknown-fields: true

In the collection awx.awx.inventory, when creating\deleting\changing an inventory the kind is a string, and the variables are a dictionary. Thats why in the cr the kind should be a string (we might make it chosen our of an enum) and the variables should either be a string or an object.

neevnuv commented 8 months ago

Linking Pull Request #139

rooftopcellist commented 6 months ago

@neevnuv Thank you for your PR, I just merged it here, so we can close this out now.