bugy / script-server

Web UI for your scripts with execution management
Other
1.57k stars 248 forks source link

Question: Passing vars for Ansible Playbook #540

Open jdotsmith opened 2 years ago

jdotsmith commented 2 years ago

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?

bugy commented 2 years ago

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

jdotsmith commented 2 years ago

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.