awx collection workflow creation

53 views
Skip to first unread message

Jason Bullen

unread,
Jun 10, 2020, 12:10:40 PM6/10/20
to AWX Project
I'm trying to get my awx deployment documented in Iac.  Trying to get workflows to create.  ran into a bug with the built int tower-cli modules that was already documented and on that git issue the recommendation was to switch over to the new collection which I have done but it is still really new and I can't find any documentation on workflow schema and survey formats supported.  For my schema, I just have a very simple list that I pulled from tower-cli but when I run that against the awx.awx tower_workflow_template module I get 

Elements value for option schema is of type <class 'str'> and we were unable to convert to dict: dictionary requested, could not parse JSON or key=value"}

The below 2 formats are what I export out from tower-cli.  Is there somewhere I can go to see the dict format the new collection is requesting??

I've tried the below two formats and this is what the module looks like:

- name: Create Server Connection workflow
tower_workflow_template:
<<: *login
name: Manage Server Connections
description: Manage server connections in AWX
organization: "{{ awx_org }}"
schema: "{{ lookup('file','./workflow_configure_ports.json') }}"
# survey: "{{ lookup('file','./workflow_configure_ports_survey.json') }}"
# survey_enabled: yes


---
- job_template: Configure Port
- job_template: Manage devices in dcim



[
{
"job_template": "Configure Port"
},
{
"job_template": "Manage devices in dcim"
}
]

Jason Bullen

unread,
Jun 10, 2020, 2:21:28 PM6/10/20
to AWX Project
I was able to get this working finally.  The problem is the easier documentation to find right now is on the older tower-cli based modules.  In that documentation, they used a lookup to load the yaml schema. lookups parse the file and returns a str.  In the collection though the tower_workflow_template wants a dictionary.  Fix that by forgoing the lookup and drop your schema into a var file.  There is also another way to do this and this is their recommend way going forward.  Use the tower_workflow_job_template_node module to create the workflow.  With this module you don't upload a schema file you build the nodes and attach to the workflow.  Something like this works:

########################
##TEMPLATES##
########################
- name: Create template Configure Ports
tower_job_template:
<<: *login
name: Configure Port
description: Configure port for server in aci
job_type: run
project: aci fabric manager
playbook: provision-port.yml
inventory: aci
vault_credential: vault
- name: Create template Manage devices in dcim
tower_job_template:
<<: *login
name: Manage devices in dcim
description: Add remove devices to racks in netbox dcim
job_type: run
project: aci fabric manager
playbook: add-device-netbox.yml
inventory: netbox
########################
##WORKFLOWS##
########################
- name: import workflow survey spec
include_vars:
file: "./workflows/Configure_Server_Port/workflow_configure_ports_survey.yml"
name: manage_server_connections_survey
- name: Create Server Connection workflow
tower_workflow_job_template:
<<: *login
name: Manage Server Connections
description: Manage server connections in AWX
organization: "{{ awx_org }}"
survey: "{{ manage_server_connections_survey }}"
survey_enabled: yes
- name: Create Server Connection nodes
tower_workflow_job_template_node:
<<: *login
identifier: Configure Port
workflow: Manage Server Connections
unified_job_template: Configure Port
organization: "{{ awx_org }}"
- name: Create Server Connection nodes
tower_workflow_job_template_node:
<<: *login
identifier: Manage devices in dcim
workflow: Manage Server Connections
unified_job_template: Manage devices in dcim
organization: "{{ awx_org }}"


Reply all
Reply to author
Forward
0 new messages