Passing Service Dialog options to CloudInit customization templates



I am trying to use service dialogs to allow someone requesting a VM to specify a puppet environment that they want to get manifests done. Currently, I am using CloudInit style customization templates, but the environment is static. I’d like this to be an option in the service dialog that i can pull into the customization template with erb.

Here is a snippet from the method called in the configurechilddialog state in a copy of the CatalogItemInitialization state machine.

task = $evm.root['service_template_provision_task']

task.set_option(:puppet_environment, $evm.root['dialog_puppet_environment'])

task.miq_request_tasks.each do |ctask|
  ctask.set_option(:puppet_environment, $evm.root['dialog_puppet_environment'])

$evm.log(:info, "PE: #{$evm.root['dialog_puppet_environment']}")

I am able to see the “PE: …” log message in automation.log and the method exits with OK status.

In my customization template, I have the following bit:

- echo "Puppet Environment: <%= evm[:puppet_environment].inspect %>"

This causes an error provisioning the VM though. I see this in evm.log:

[----] I, [2017-05-03T15:17:11.880849 #30175:eecc6c]  INFO -- : Q-task_id([miq_provision_57]) <AutomationEngine> Calling Create Notification type: automate_user_error subject type: MiqRequest id: 34 options: {:message=>"VM Provision Error: [] VM [testvm] Step [CheckProvisioned] Status [[Psych::SyntaxError]: (<unknown>): did not find expected key while parsing a block mapping at line 29 column 3] Message [[Psych::SyntaxError]: (<unknown>): did not find expected key while parsing a block mapping at line 29 column 3] "}

What I would like to know is how to access the options from the service dialog. Any ideas?


Hi @trzejos
It looks like that error is not related to your variable. Try to run the deployment without the variable and not use the inspect method.


This worked after I removed the inspect method call with the expected values.