awx icon indicating copy to clipboard operation
awx copied to clipboard

Ability to run playbooks in an EE collection without associated project

Open AlanCoding opened this issue 1 year ago • 5 comments

Please confirm the following

  • [X] I agree to follow this project's code of conduct.
  • [X] I have checked the current issues for duplicates.
  • [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.

Feature type

New Feature

Feature Summary

There is a feature in Ansible-core to run a playbook that exists inside of a collection:

https://docs.ansible.com/ansible/latest/collections_guide/collections_using_playbooks.html#using-a-playbook-from-a-collection

This is an issue to gain feature-parity with this ability in AWX.

Specifying a playbook inside of a collection, inside of an execution environment, can be done by the FQCN name of the playbook, as explained in the linked docs.

This would replace what is now provided by the job template fields project and playbook fields. Whether a new field may be introduced, or existing fields abused for this purpose is left as an issue for implementation.

Select the relevant components

  • [X] UI
  • [X] API
  • [ ] Docs
  • [ ] Collection
  • [ ] CLI
  • [ ] Other

Steps to reproduce

Run on Ansible CLI

ansible-playbook my_namespace.my_collection.playbook1 -i ./myinventory

Try to do same thing in AWX

Current results

Can't do it.

Sugested feature result

Ability to run playbook defined by FQCN my_namespace.my_collection.playbook1, as an example.

Additional information

Implementation could go in many different directions:

  • allow null project, put FQCN in playbook field
  • Force creating a new project for this purpose, possibly via a new scm_type option to "defer to EE", this maybe a coherent way for us to perform an async operation to inspect the image and obtain a playbook list, and requiring no other changes to the existing UX around job templates
  • other possibilities that I have not thought of

This is related to the existing issues https://github.com/ansible/awx/issues/3780 and https://github.com/ansible/awx/issues/3776. While 3780 would provide something similar via a different content mechanism, and 3776 is old, vague, generally unclear, and doesn't necessarily ask for this RFE.

AlanCoding avatar Jun 14 '23 15:06 AlanCoding

we have had hit or miss on doing this inside the redhat_cop playbooks, as customers seem to think it is the ONLY way to use the collection/roles, but that is more on the feature and customer assumptions, would love for this ability in AWX

sean-m-sullivan avatar Jun 14 '23 15:06 sean-m-sullivan

This is similar to something I did here, which made the project optional on jt definition: https://github.com/ansible/awx/pull/12250

Which I think may be the right way to go.

matburt avatar Jun 14 '23 17:06 matburt

If you use a null project, that means the user would manually type in the FQCN for the playbook. That should work, but it is in-congruent with the current user experience which offers a drop-down selection of playbooks.

I've argued that not collecting metadata for EEs is a problem, see https://github.com/ansible/awx/issues/10409

If we collected the EE metadata then we could populated a suggested playbook list after the user selects the JT execution_environment. Normally this is optional (as it falls back to default), but that brings up a good point - that perhaps we should require an explicit EE on the JT to use this feature. Just a thought.

AlanCoding avatar Jun 14 '23 19:06 AlanCoding

hey! :D that's nice! I would love to have this feature. I was talking to @relrod and I already this problem.

thenets avatar Jun 20 '23 19:06 thenets

+1 for this feature.

my two cents.

specifying the fqcn in the playbook fields could be parsed with regex ![\.yml|\.yaml]$ this along with either an additional check box ( is collection ) or using the project field with a unique (i.e. __collection[-1.0.0]) value could be enough to tell AWX it's a collection project.

  • collection downloads is turned off, it wont download the collection and will expect it in the EE and use ansible.cfg to locate the collection, if not there fail.
  • collection downloads turned on, download before running and use that one, unless overridden by ansible.cfg or it could take precedence over ansible.cfg???.

jon-nfc avatar Feb 15 '24 05:02 jon-nfc