This is what we do. When we know lots of different services and workflows require a given collection we add it to the AWX (Ansible Tower) controller so the projects themselves don't have to worry about them.
Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Oct 10, 2022, at 11:28 AM, Matt Martz <[email protected]<mailto:[email protected]>> wrote: If you are using awx, you can just create a `collections/requirements.yml` file that can specify those needed collections. See: https://github.com/ansible/awx/blob/devel/docs/collections.md On Mon, Oct 10, 2022 at 10:25 AM Todd Lewis <[email protected]<mailto:[email protected]>> wrote: Alas, these projects all run on AWX, so we can't rely on documented extra steps. It needs to work using the existing AWX scm update processes. We get away with it as long as the required collections are already installed in one of the collection path directories. And they often will be on local workstations or AWX. But we obviously can't rely on that. We'll either have to move these roles into our "collection-common" project from which we build our common collection, adding the dependencies to galaxy.yml there, or we'll need to ensure through our CI pipelines that projects pulling in the common roles include their required collections in each project's collections/requirements.yml. This is not at all the answer I was expecting. But at least I can quit trying to make the unworkable work. On Monday, October 10, 2022 at 10:01:08 AM UTC-4 Richard Megginson wrote: Right - there is no mechanism in Ansible to do this. This is what we did for linux system roles - https://linux-system-roles.github.io/documentation/role-requirements.html<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flinux-system-roles.github.io%2Fdocumentation%2Frole-requirements.html&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5e17fe91ffa64cec0e7a08daaad43d5a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638010125792920492%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Sq%2FxaGhCtP9S3P6u2sD8muxB93gOU3JUa8Iuujrq7HY%3D&reserved=0> - basically, made up our own file and rely on documentation. On Mon, Oct 10, 2022 at 7:41 AM Matt Martz <[email protected]> wrote: You should generally not do this. If you have content that is distributed, it should only rely on others of its type. A standalone role on a standalone role, or a collection on a collection. Note that collections can contain roles. As such, there is no automatic installation of dependencies. Should you wish to keep your use of standalone roles with dependencies on collections you would just have to rely on documentation. And maybe insert some form of canary test, that tries to use a module you need, wrapped in a block/rescue that then provides a friendly error when the module is not available. On Mon, Oct 10, 2022 at 8:35 AM Todd Lewis <[email protected]> wrote: We have a handful of "common" roles that are used by many of our Ansible projects. These projects list their required roles in their respective roles/requirements.yml files. Nothing surprising here; it's worked this way for years. With recent maintenance, one of these "common" roles has started using bits from a couple of collections — community.general and ansible.utils. From reading the docs, I erroneously thought I could specify those collections in meta/requirements.yml like so: --- collections: - name: community.general - name: ansible.utils However, that's wrong. (See this<https://github.com/ansible/ansible/issues/73732> for details.) Evidently meta/requirements.yml must be in "v1" format, which is just a list of roles; no "roles:" or "collections:" dict allowed. So how does a required role specify the collections on which it depends? -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f6fafb0d-b072-4252-9115-4132663221d9n%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2Ff6fafb0d-b072-4252-9115-4132663221d9n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5e17fe91ffa64cec0e7a08daaad43d5a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638010125792920492%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=7jf2%2Bf94WZB9S7QCFuv5lz9t9kfHA5zoWaowubTbfOs%3D&reserved=0>. -- Matt Martz @sivel sivel.net<https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsivel.net%2F&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5e17fe91ffa64cec0e7a08daaad43d5a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638010125792920492%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mhBEuZaiqdo8K74Rqpe0G49xsjpUJvyKP3IigMi02II%3D&reserved=0> -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAD8N0v-X_3HTBZ-3ex2%2BXh-STOBtdHqTeBHZJEOqMA5KQwjH5g%40mail.gmail.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCAD8N0v-X_3HTBZ-3ex2%252BXh-STOBtdHqTeBHZJEOqMA5KQwjH5g%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5e17fe91ffa64cec0e7a08daaad43d5a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638010125792920492%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=53mibbyWB8yut2jMEDXsFGMZSyi%2BLFDPGhBnczgQAGk%3D&reserved=0>. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b6d1384d-14cb-4ebc-ba2e-1bf8a7a6001bn%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2Fb6d1384d-14cb-4ebc-ba2e-1bf8a7a6001bn%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5e17fe91ffa64cec0e7a08daaad43d5a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638010125792920492%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=b%2FVuGeDFnf0g6sLRNXRmrsPkHD6dDFz1jE5Geot6Uu0%3D&reserved=0>. -- Matt Martz @sivel sivel.net<https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsivel.net%2F&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5e17fe91ffa64cec0e7a08daaad43d5a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638010125792920492%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mhBEuZaiqdo8K74Rqpe0G49xsjpUJvyKP3IigMi02II%3D&reserved=0> -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAD8N0v9M62P5chkHFNbjQHdw7THVaFLh0o%2B-ucOToGQS2UBqVw%40mail.gmail.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCAD8N0v9M62P5chkHFNbjQHdw7THVaFLh0o%252B-ucOToGQS2UBqVw%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5e17fe91ffa64cec0e7a08daaad43d5a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638010125793077363%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=dpPtkuEwe6MtclqzShFFJiw6YonJmLz2gfwl884%2F2Rg%3D&reserved=0>. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0036F0FB-D44F-4FCF-A1AD-2D20A8E1DD1D%40nist.gov.
