ansible-runner icon indicating copy to clipboard operation
ansible-runner copied to clipboard

[Tech debt] Put the standard out callback into a collection

Open AlanCoding opened this issue 4 years ago • 1 comments

The standard out callback for this project is extremely old, and has not been updated to changes that Ansible content have been adoption elsewhere.

Proposal: Place the awx_display (and minimal) callback plugins in a collection. Enable use of this collection, as opposed to the callback plugin.

I previously made a small attempt to convert this into a collection at https://github.com/ansible/ansible-runner/pull/409, but it's a project of significant scope and impact.

Python import hacks resolvable by module_utils

The callback receiver puts code in multiple modules, and it allows for this by modifying sys.path. (the mention of the awx/lib folder is out of date, was before the split from awx)

https://github.com/ansible/ansible-runner/blob/dd5de99e9e9202eed620b8c02c9c06c586925e2f/ansible_runner/callbacks/awx_display.py#L38-L41

Now, you can much more easily break your code into multiple modules by putting modules into module_utils inside of a collection.

This would also probably resolve the import issue addressed with the other hack for import order.

https://github.com/ansible/ansible-runner/blob/dd5de99e9e9202eed620b8c02c9c06c586925e2f/ansible_runner/display_callback/minimal.py#L27-L29

Testing the plugin via ansible-test

Many other projects are making heavy use of ansible-test checks. You can do unit and integration tests. Unit tests would probably be useful for this project.

Enabling the collection as opposed to the plugin

We use an environment variable to enable the standard out callback.

https://github.com/ansible/ansible-runner/blob/1a8c1c59e010ac87966a552b6d3f9f52aa1abe1e/ansible_runner/config/_base.py#L270

If this is maintained as a collection, we would change this to modify ANSIBLE_COLLECTIONS_PATH instead. That option has some risk that custom collection paths in the user's ansible.cfg could get overwritten. This is an additional challenge, which would be resolved by parsing the config file, or by placing the collection in a special place in execution environment images.

AlanCoding avatar Oct 27 '21 16:10 AlanCoding

I missed this:

https://github.com/ansible/ansible-runner/blob/1a8c1c59e010ac87966a552b6d3f9f52aa1abe1e/ansible_runner/config/_base.py#L262

We add the callback dir to the PYTHONPATH in the ansible subprocess. Only if it's not containerized. That sounds like it is based on incorrect assumptions (it may not be necessary right now), but it's obviously not good.

AlanCoding avatar Nov 01 '21 14:11 AlanCoding