ansible / awx-resource-operator

41 stars 34 forks source link

use extra_vars and inventory when launching job #7

Closed mikeshng closed 4 years ago

mikeshng commented 4 years ago

Signed-off-by: Mike Ng ming@redhat.com

*edited after discussion in comments.

An AnsibleJob CR example with extra_vars:

apiVersion: tower.ansible.com/v1alpha1
kind: AnsibleJob
metadata:
  name: bigjoblaunch
spec:
  tower_auth_secret: toweraccess
  job_template_name: Target Clusters Template
  extra_vars: 
    target_clusters: ["aaa_cluster","bbb_cluster","ccc_cluster"]
maxamillion commented 4 years ago

As per the awx.awx.tower_job_launch documentation the data type of the extra_vars being passed in should be a dict. This differs from what the Ansible command line tool expects because we're targeting the AWX/Tower REST API for job launching on the backend of the task that calls the awx.awx.tower_job_launch module instead of Ansible the command line tool.

    extra_vars:
      description:
        - extra_vars to use for the Job Template.
        - ask_extra_vars needs to be set to True via tower_job_template module
          when creating the Job Template.
      type: dict
mikeshng commented 4 years ago

EDIT: out of date comment. extra_vars is now object type.

@maxamillion thanks for the good catch. But there is no dict or even a map type that I can define easily in the CRD. The list of options are:

Unsupported value: "dict": supported values: "array", "boolean", "integer", "number", "object", "string"

For ease of use, I think we should stick with the JSON string. I've updated the description for the field in the CRD. What do you think?

mikeshng commented 4 years ago

for https://github.com/open-cluster-management/backlog/issues/4228