script-server icon indicating copy to clipboard operation
script-server copied to clipboard

Question: Passing vars for Ansible Playbook

Open jdotsmith opened this issue 3 years ago • 2 comments

This isnt an issue, more like a question, but I didnt know where else to post it.

So I have an ansible playbook that has a couple vars in a vars.yml file. Id like to pass those vars into the script server as some parameters but Im not sure how. I can get the playbook to run just fine using the variables that are already in my vars.yml file.

My script path is ansible-playbook main.yml My working directory is the location of the playbook.

In my vars.ymlfile I have param1, param2 and param3. In my playbook i have those as variables {{ param1 }} etc. Do I need to pass those asextra-vars in my script path and then add those vars as parameters in the script?

jdotsmith avatar Mar 13 '22 17:03 jdotsmith

Hi @jdotsmith, to be honest I don't know anything about ansible. But most probably, you can pass those vars via command line (i guess this is the right approach https://stackoverflow.com/questions/30662069/how-can-i-pass-variable-to-ansible-playbook-in-the-command-line as you suggested too) Unfortunately, script server doesn't allow passing variables in this format, it always passes every variable as a separate argument. In this case a separate wrapping script would be needed. Which would take separate arguments passed by script server, and called Ansible with those arguments merged together

bugy avatar Mar 16 '22 07:03 bugy

Yeah. Script server runs my command just fine, but takes the current variables. I could potentially have script-server populate the vars file for me with a script I suppose. Thanks for getting back to me.

jdotsmith avatar Mar 16 '22 07:03 jdotsmith