Closed NitroCao closed 1 year ago
By the way, it works fine when executing ansible-playbook directly. My workaround is to catch the exception and initialize self._json_indent
to 0
in the exception handler.
Yes, having exactly the same issue when calling ansible-runner from Python code. Running playbook directly or using other callback plugins gives no errors
Closing as duplicate.
@NitroCao I also have the same problem, how did you fix it?
How to reproduce:
export ORIGINAL_STDOUT_CALLBACK=ansible.posix.json
ansible-runner run . -p /tmp/demo-playbook.yaml --inventory hosts --omit-event-data --cmdline='-vvv'
/tmp/demo-playbook.yaml
is:ansible-playbook [core 2.15.0] config file = /etc/ansible/ansible.cfg configured module search path = ['/home/nitro/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.11/site-packages/ansible ansible collection location = /home/nitro/.ansible/collections:/usr/share/ansible/collections executable location = /usr/bin/ansible-playbook python version = 3.11.3 (main, Apr 5 2023, 15:52:25) [GCC 12.2.1 20230201] (/usr/bin/python) jinja version = 3.1.2 libyaml = True Using /etc/ansible/ansible.cfg as config file host_list declined parsing /home/nitro/Development/vulnk8s/ansible/hosts as it did not pass its verify_file() method script declined parsing /home/nitro/Development/vulnk8s/ansible/hosts as it did not pass its verify_file() method auto declined parsing /home/nitro/Development/vulnk8s/ansible/hosts as it did not pass its verify_file() method Parsed /home/nitro/Development/vulnk8s/ansible/hosts inventory source with ini plugin [WARNING]: Found both group and host with same name: master ERROR! Unexpected Exception, this is probably a bug: 'json_indent' the full traceback was:
Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/ansible/cli/init.py", line 659, in cli_executor exit_code = cli.run() ^^^^^^^^^ File "/usr/lib/python3.11/site-packages/ansible/cli/playbook.py", line 156, in run results = pbex.run() ^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/ansible/executor/playbook_executor.py", line 119, in run self._tqm.load_callbacks() File "/usr/lib/python3.11/site-packages/ansible/executor/task_queue_manager.py", line 203, in load_callbacks self._stdout_callback = callback_loader.get(self._stdout_callback) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/ansible/plugins/loader.py", line 855, in get return self.get_with_context(name, *args, *kwargs).object ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/ansible/plugins/loader.py", line 906, in get_with_context obj.init(instance, args, **kwargs) # pylint: disable=unnecessary-dunder-call ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nitro/.local/lib/python3.11/site-packages/ansible_runner/display_callback/callback/awx_display.py", line 343, in init super(CallbackModule, self).init() File "/usr/lib/python3.11/site-packages/ansible_collections/ansible/posix/plugins/callback/json.py", line 76, in init self._json_indent = self.get_option('json_indent') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/ansible/plugins/callback/init.py", line 173, in get_option return self._plugin_options[k]