ansible-runner
ansible-runner copied to clipboard
The collections.json data is not JSON if ANSIBLE_DEBUG is set
Run a job with "ANSIBLE_DEBUG": 1 within the environment variables you give it.
Then it will output a collections.json file that looks something like this:
18 1618853453.51286: starting run
18 1618853453.90290: Validate TLS certificates for https://galaxy.ansible.com: True
{"/usr/share/ansible/collections/ansible_collections": {"ovirt.ovirt": {"version": "1.4.1"}, "awx.awx": {"version": "18.0.0"}, "community.vmware": {"version": "1.9.0"}, "community.kubernetes": {"version": "1.2.0"}, "theforeman.foreman": {"version": "2.0.1"}, "ansible.posix": {"version": "1.2.0"}, "amazon.aws": {"version": "1.4.1"}, "azure.azcollection": {"version": "1.5.0"}, "google.cloud": {"version": "1.0.2"}, "openstack.cloud": {"version": "1.0.1"}}}
This is because the ansible-core code will output debug statements in the code path, like:
https://github.com/ansible/ansible/blob/1c83672532330d0d26b63f8a97ee703e7fc697df/lib/ansible/galaxy/role.py#L60
Of course, this means the the *.json file is not valid JSON.
In other similar cases of Ansible commands where actual JSON is needed, like ansible-inventory, we moved to using an --output-file option, because the standard out cannot be guaranteed to be unadulterated for purposes of JSON data.