How to pass dialog values to embedded ansible playbook

Hi,

I have something like this

I can see the value in the object walker

 |    |    $evm.root['miq_provision'].options[:dialog_password] = test-1   (type: String

But it is not passed to the playbook

INFO -- : Q-task_id([miq_provision_1000000000228]) Invoking [playbook] method [/TALMER/Infrastructure/VM/Provisioning/StateMachines/Methods/change_root_password] with inputs [{"password"=>""}]

Is there any way to pass the values from the dialog inside the embedded ansible call? This must be done as a part of provisioning process and must be non interactively.

Your parameter default value of ${/#dialog_password} is trying to translate $evm.root['dialog_password'] which probably doesn’t exist. Try something like ${/#miq_provision.options.fetch(:dialog_password)}

1 Like

Hi, thank you for your help. Can you please share the doc, where I can find complete list of methods available for substitution? (Didn’t know there was ‘fetch’ method here)

fetch is standard Ruby (https://apidock.com/ruby/Hash/fetch) and is a useful way of accessing a hash key.

value = my_hash[:this_key]
value = my_hash.fetch(:this_key)

It’s especially useful in a substitution string where the ‘[’ & ‘]’ characters are not legal.

pemcg

So any ruby method is valid here? And what are the limitations? Except for the ‘[’ ‘]’?

This is a description of the change with MIQ Fine that allowed methods with arguments as substitution strings: https://manageiq.gitbook.io/mastering-cloudforms-automation-addendum/updates/chapter-4#methods-with-arguments-in-substitution-strings

pemcg

Thank you for your help!

This is exactly what I have been looking for all day. We had been trying to use
${/#dialog_vm_name} directly to pass to the embedded ansible playbook. The example in the addendum is somewhat misleading in that I thought you could always access the dialog evm.root environment variable. Did not know that it depends on the context of the workflow and that you had to fetch it out of the objects.

Thank you posting this and providing an answer to this!!! My ansible playbook is now happy!