$re = '/(?:changed: \[)([A-Za-z0-9-.]+)(?:\]) => (\{([^{}]|(?R))*\})/s';
$str = 'ansible-playbook 2.4.6.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u\'/var/lib/awx/.ansible/plugins/modules\', u\'/usr/share/ansible/plugins/modules\']
ansible python module location = /opt/my-envs/ansible2.4_py2-7/lib/python2.7/site-packages/ansible
executable location = /opt/my-envs/ansible2.4_py2-7/bin/ansible-playbook
python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /tmp/awx_29075__71hcp3b/tmpl6ec9o_0 inventory source with script plugin
[DEPRECATION WARNING]: \'include\' for playbook includes. You should use
\'import_playbook\' instead. This feature will be removed in version 2.8.
Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.
Loading callback plugin awx_display of type stdout, v2.0 from /var/lib/awx/venv/awx/lib/python3.6/site-packages/ansible_runner/callbacks/awx_display.py
PLAYBOOK: playbook_deploy_main.yml *********************************************
2 plays in playbook_deploy_main.yml
PLAY [Installing configuration to JUNOS device] ********************************
META: ran handlers
TASK [Install rendered configuration to acm-lab-core1.expedient.com] ***********
task path: /var/lib/awx/projects/_23__deploy/playbook_deploy_juniper.yml:7
<acm-lab-core1.expedient.com> using connection plugin netconf
<acm-lab-core1.expedient.com> socket_path: /var/lib/awx/.ansible/pc/d05e057c6f
Using module file /opt/my-envs/ansible2.4_py2-7/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.py
<acm-lab-core1.expedient.com> ESTABLISH LOCAL CONNECTION FOR USER: awx
<acm-lab-core1.expedient.com> EXEC /bin/sh -c \'echo ~ && sleep 0\'
<acm-lab-core1.expedient.com> EXEC /bin/sh -c \'( umask 77 && mkdir -p "` echo /var/lib/awx/.ansible/tmp/ansible-tmp-1580756130.95-273172941190466 `" && echo ansible-tmp-1580756130.95-273172941190466="` echo /var/lib/awx/.ansible/tmp/ansible-tmp-1580756130.95-273172941190466 `" ) && sleep 0\'
<acm-lab-core1.expedient.com> PUT /tmp/tmpv0PKXI TO /var/lib/awx/.ansible/tmp/ansible-tmp-1580756130.95-273172941190466/junos_config.py
<acm-lab-core1.expedient.com> EXEC /bin/sh -c \'chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1580756130.95-273172941190466/ /var/lib/awx/.ansible/tmp/ansible-tmp-1580756130.95-273172941190466/junos_config.py && sleep 0\'
<acm-lab-core1.expedient.com> EXEC /bin/sh -c \'/usr/bin/python /var/lib/awx/.ansible/tmp/ansible-tmp-1580756130.95-273172941190466/junos_config.py; rm -rf "/var/lib/awx/.ansible/tmp/ansible-tmp-1580756130.95-273172941190466/" > /dev/null 2>&1 && sleep 0\'
[WARNING]: argument username has been deprecated and will be removed in a
future version
[WARNING]: argument host has been deprecated and will be removed in a future
version
[WARNING]: argument timeout has been deprecated and will be removed in a
future version
[WARNING]: argument password has been deprecated and will be removed in a
future version
changed: [acm-lab-core1.expedient.com] => {
"changed": true,
"failed": false,
"invocation": {
"module_args": {
"backup": false,
"comment": "configured by junos_config",
"confirm": 0,
"confirm_commit": false,
"host": "acm-lab-core1.expedient.com",
"lines": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": null,
"provider": null,
"replace": null,
"rollback": null,
"src_format": "text",
"ssh_keyfile": null,
"timeout": 300,
"transport": null,
"update": "merge",
"username": "svcansible",
"zeroize": false
}
}
}';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php