Hello,
I am trying to get some assistance with the following. I am using a Boolean
inputs:
app1:
type: boolean
title: SQL
default: false
app2:
type: boolean
title: IIS
default: false
I would like to then be able to pass this into an input which will call ansible playbook that will match then the app1 or app2 tittle (SQL or IIS etc) which will be the name of the Ansible playbook in the controller.
------------------------
Cloud_Ansible_1:
type: Cloud.Ansible
properties:
----------------------
playbooks:
provision:
- /home/ansible/playbook.yml
- '${input.app1 == "true" ? "/home/ansible/sql.yaml" : ””}' -----> Run the following if the App1 is true .
but for some reason the value is not working and instead I am getting an error with:
The only playbook run options supported are playbook level variables (Specified by -e OR --extra-vars). Please correct the following playbooks specified with unsupported options: ${input.app1
Can someone provide some assistance? maybe I am doing something wrong or something needs to be different?
Thank you
I wonder if the error might be due to having a null value in there when app1 isn't true?
Defaulting to a valid-but-empty playbook path might be an option:
resources:
Cloud_Ansible_1:
type: Cloud.Ansible
properties:
[...]
playbooks:
provision:
- /home/ansible/playbook.yml
- '${input.app1 ? "/home/ansible/app1.yml" : "/home/ansible/empty.yml"}'
- '${input.app2 ? "/home/ansible/app2.yml" : "/home/ansible/empty.yml"}'
Just a guess though. I don't have access to Ansible in my lab at the moment so I can't test this myself. It works in my head though!
Can you try literal null instead of empty string "" after the colon? (I can't try either as not using Ansible here.)
inputs: App1: type: boolean Default: false title: App1 resources: 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 groups: - win2012 host: ${resource.AnsibleWindowsVM.*}
This should work error was occurring since we were passing true in quotes which was making it string ,instead of predefined type of boolean
Hi,
Not sure what is creating the exact problem but it seems to me that the variable is represented as an ansible variable. On the other hand, check the following blog on achieving it in another way.
https://www.mobius.co.uk/deeper-look-at-the-vrealize-automation-and-ansible-open-source-integration/
I know it is not a direct answer to your question, but will let you achieve what you want to do. For the exact problem, I need to test it myself and unfortunately I do not have this setup in my environment.
I wonder if the error might be due to having a null value in there when app1 isn't true?
Defaulting to a valid-but-empty playbook path might be an option:
resources:
Cloud_Ansible_1:
type: Cloud.Ansible
properties:
[...]
playbooks:
provision:
- /home/ansible/playbook.yml
- '${input.app1 ? "/home/ansible/app1.yml" : "/home/ansible/empty.yml"}'
- '${input.app2 ? "/home/ansible/app2.yml" : "/home/ansible/empty.yml"}'
Just a guess though. I don't have access to Ansible in my lab at the moment so I can't test this myself. It works in my head though!
This is currently being reviewed , whether if else is supported under ansible code block or not
Can you try literal null instead of empty string "" after the colon? (I can't try either as not using Ansible here.)
inputs: App1: type: boolean Default: false title: App1 resources: 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 groups: - win2012 host: ${resource.AnsibleWindowsVM.*}
This should work error was occurring since we were passing true in quotes which was making it string ,instead of predefined type of boolean
Thanks Ankush. This should definitely solve it. Missed that point. After al it is a syntax problem.
Thank you all for your assistance! 🙂