I have a simple PHP script that runs ansible-playbook and polls the output. It seems that ansible runs to completion before it displays the output.
This is my simple code:
(process.php)
`
$handle = popen(“ansible-playbook set-mysqld-max-connection-with-template.yml”, “r”);
while(!feof($handle)) {
$buffer = fgets($handle);
echo $buffer . “\n”;
usleep(100000); //sleep for 0.1 seconds
}
pclose($handle);
`
Output:
`
PLAY [web] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [selenium1.example.com]
TASK: [set-mysqld-max-connection-with-template | set mysqld (my.cnf) max_connection with template] ***
ok: [selenium1.example.com]
PLAY RECAP ********************************************************************
selenium1.example.com : ok=2 changed=0 unreachable=0 failed=0
`