On Sun, Feb 9, 2020, 4:23 PM Orion Poplawski <orion@nwra.com> wrote:
On 2/9/20 2:58 AM, Igor Gnatenko wrote:
> Hello,
>
> Did anybody had an experience of packaging Ansible collections into an RPM?
>
> I guess if would be enough to put the files somewhere under
> /usr/share/ansible, but not sure. Also I'm not sure what download URL
> could be used.

It seems to me that "ansible-galaxy collection install" simply unpacks
the tarball.  So, this seems reasonable to me:

Name: ansible-collection-%{namespace}-%{pkgname}
Source0:
https://galaxy.ansible.com/download/%{namespace}-%{pkgname}-%{version}.tar.gz

%install
mkdir -p
%{buildroot}%{_datadir}/ansible/collections/ansible_collections/%{namespace}/%{name}
tar xf %SOURCE0 -C
%{buildroot}%{_datadir}/ansible/collections/ansible_collections/%{namespace}/%{pkgname}

 i had a preliminary look at this a few months ago (because ansible 2.10 will ship most of the modules and plugins inside of collections instead of the ansible tarball) and there are some issues...

* Collections aren't necessarily noarch.  Ansible modules can be written in any language so a collection can theoretically contain a precompiled binary module

* Collections aren't actually source code.  Shipping something based on the collection as source0 could run into gpl or practical concerns due to this.  If you take the theoretical compiled collection case again, the collection would contain the compiled module but might not contain the source code or any build scripts to build that module.

Because of those, i recommend downloading the true source of the collection (i believe the openstack collection use the git repo as it's source?)

Another note: I've been talking with the ansible core team and they are going to add the ability to install ansible collections in a place that pip could install them to.  That means with ansible 2.10 you should be able to install into site-packages somewhere.  This may be something you want to take advantage of so noarch collections can be packaged under /usr/lib and archful packages go under /usr/lib64 (if appropriate on that platform)

Last note: I think i had been using the ansible-galaxy tool with appropriate command line args to control the directory unpacked collections ended up in. At the moment it doesn't do anything different than the tar commands orion posted above but i don't know whether that will hold true into the future.

-Toshio


--
Orion Poplawski
Manager of NWRA Technical Systems          720-772-5637
NWRA, Boulder/CoRA Office             FAX: 303-415-9702
3380 Mitchell Lane                       orion@nwra.com
Boulder, CO 80301                 https://www.nwra.com/

_______________________________________________
packaging mailing list -- packaging@lists.fedoraproject.org
To unsubscribe send an email to packaging-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.org