Hello,
We are looking for a way to use a Multi Select (constant value) if the value is "yes" or "checked" we would like to run an ansible playbook. Ideally we would like to keep it simple within the cloud template/blueprint as part of the YAML code (like shown below with the "oneOf".
I did some fumbling about with this today and I think I have a solution, at least for the input side of things.
I start out by adding a 'playbooks' input to my Cloud Template, of type 'array' so that it can hold multiple strings:
inputs:
playbooks:
type: array
title: Playbooks
description: Ansible playbooks to run
items:
type: object
properties:
playbook:
type: string
title: Playbook
On the Custom Form side, I can set the field to be a Multi Value Picker and set the values to a few playbook names I want to be available:
(The first line of the values CSV is the header and needs to match the property specified in the template, 'playbook' in this instance.)
And then it shows up correctly when requesting the catalog item:
Of course, this is going to return an array of playbook names back to vRA. I'm not sure how best to handle breaking it out to discrete strings for the ansible provisioner to handle. I might experiment with that some in the future, but this is about as far as I could get it in my free time today. Maybe it'll at least help to nudge you in the right direction?
Thanks John, the main issue I am facing is that I don't know a way to pass the value that's chosen as an input to call the playbook. I can name the playbook to match the value but how do I get that value as part of a input. I don't need to use a multi select but I need to use something like a checkbox type solution so they can check the option for the app they need and then execute the playbook.
Yeah I've been poking a bit more at it and haven't come up with a way to handle that within the Ansible resource section of the template. BTW a Data Grid display type might make more sense so that users could select the checkboxes for what they want rather than having to search for it. Same issue on the backend, though - still need to figure out how to convert an array of strings into something that could be processed by the Ansible provisioner.
Thanks John.
you can try with boolean and conditional logic.
Ansible:
type: Cloud.Ansible
metadata:
layoutPosition:
- 0
- 1
properties:
account: eso-ansible
username: administrator
password: Dynam1c0ps
maxConnectionRetries: 20
playbooks:
provision:
- '${input.App1 == true ? "/root/ansible-playbooks/windows_enableiis.yml" : ""}'
osType: windows
inventoryFile: /root/ansible-playbooks/windowshosts