S
S
Sanes2016-05-03 21:48:49
PHP
Sanes, 2016-05-03 21:48:49

How to correctly pass a string to --extra-vars Ansible?

Using a PHP script, I pass an argument to the Playbook Ansible as follows

foreach ($all as $k => $v) {
$title = $v['title'];
--------------------------
passthru("ansible-playbook -i /home/vagrant/inventory.ini /home/vagrant/add.yml --tags $cms --extra-vars 'username=$userName userpass=$userPass mysql_user_pass=$mysqlPass domain=$domain title=$title'");

If the variable contains 2 words, for example Test site Then only the first word Test is passed .
Arrives in the template
$sitename = 'Тестовый';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2016-05-03
@Sanes

0) figure out how to run a playbook with extra-vars parameters in a few words
1) figure out how to correctly form such a call from the php side
2) ...
3) profit!
Hint: more quotes plus escapeshellarg, escapeshellcmd

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question