Bug 255920

Summary: sysutils/ansible-sshjail: Ansible cannot find the module in its module path
Product: Ports & Packages Reporter: Mateusz Piotrowski <0mp>
Component: Individual Port(s)Assignee: Mateusz Piotrowski <0mp>
Status: Closed FIXED    
Severity: Affects Only Me CC: 0mp, lcook
Priority: --- Flags: madpilot: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Description Flags
ansble-base patch madpilot: maintainer-approval? (0mp)

Description Mateusz Piotrowski freebsd_committer 2021-05-16 12:49:31 UTC
After recent updates to sysutils/ansible, the Ansible modules installed via ports like sysutils/ansible-sshjail are not automatically found by the ansible program.

We need to address that. The fix is likely to install modules under  a different path.

We may also add a test target with a command like "ansible localhost -m modulename  --check" to avoid such breakage in the future.

- https://docs.ansible.com/ansible/latest/dev_guide/developing_locally.html
Comment 1 Guido Falsi freebsd_committer 2021-05-16 13:06:05 UTC
I agree we can use another path for installation. I'm going to create a patch to this effect.
Comment 2 Lewis Cook freebsd_committer freebsd_triage 2021-05-16 14:04:36 UTC
Good point.  Now, I'm wondering whether or not it would be useful introducing a new USES=ansible (for lack of better names) target to reduce some of the boilerplate and define a do-test target too.  Maybe something like...


.if !${USES:Mpython*}
.include "${USESDIR}/python.mk"

RUN_DEPENDS+=    ${PYTHON_PKGNAMEPREFIX}ansible>0:sysutils/ansible@${PY_FLAVOR}

_ANSIBLE_PREFIX?=    share/ansible


.if !target(do-test):
    # Foo, baz

...in Mk/Uses/ansible.mk.  Thoughts?
Comment 3 Guido Falsi freebsd_committer 2021-05-17 07:40:59 UTC
Created attachment 225011 [details]
ansble-base patch

I've made some tests and noticed the ansible base uses the following:

${FIND} ${WRKSRC} -not -regex '${WRKSRC}/test/units/cli/galaxy/test_execute_list_collection.py' -type f -print0 | \
                ${XARGS} -0 ${REINPLACE_CMD} \
                        -e 's|/etc/ansible|${ETCDIR}|g' \
                        -e 's|/usr/share/ansible|${DATADIR}|g'

By using DATADIR it point the search paths to /usr/local/share/py38-ansible-base/plugins which looks wrong. also this causes this substitution to create a different path than the one in the ansible port. Upstream code shown they are intended to be the same.

So I created the attached patch to address this and put back the original search path

Regarding adding a uses it looks like a good idea, but first we should correct the search path and then make such USES point to it.
Comment 4 commit-hook freebsd_committer 2021-05-17 10:22:48 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c8e37b455176cb3c016a50c671226a9d88f89570

commit c8e37b455176cb3c016a50c671226a9d88f89570
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2021-05-17 09:59:21 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2021-05-17 09:59:21 +0000

    sysutils/py-ansible-*: Fix DATADIR for Ansible plugins

    All the Ansible plugins assume that the Ansible DATADIR is
    ${PREFIX}/share/${PYTHON_PKGNAMEPREFIX}ansible instead of
    ${PREFIX}/share/${PYTHON_PKGNAMEPREFIX}ansible-base or

    This patch sets the DATADIR back to its historical value. It's based on
    a patch provided by madpilot.

    PR:     255920
    Reported by:    madpilot

 sysutils/py-ansible-base/Makefile | 4 +++-
 sysutils/py-ansible-core/Makefile | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Comment 5 Mateusz Piotrowski freebsd_committer 2021-05-17 10:23:50 UTC
(In reply to Guido Falsi from comment #3)

I've modified the patch a bit and also updated sysutils/py-ansible-core.

I'm almost done with ansible.mk. I'll keep you posted.
Comment 6 Mateusz Piotrowski freebsd_committer 2021-05-17 11:58:33 UTC
(In reply to Lewis Cook from comment #2)

I've published my ansible.mk on phabricator: https://reviews.freebsd.org/D30312
Comment 7 Mateusz Piotrowski freebsd_committer 2021-05-17 12:25:34 UTC
I'll close this PR as the modules should be working again. ansible.mk is just something extra we are adding to the framework.
Comment 8 commit-hook freebsd_committer 2021-05-17 13:39:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=92939bfde271f881e76fdb94ee5047271d2d1b43

commit 92939bfde271f881e76fdb94ee5047271d2d1b43
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2021-05-17 11:51:15 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2021-05-17 13:38:41 +0000

    Add USES=ansible for Ansible ports

    The purpose of this new USES file is to provide a central place for
    setting Ansible paths for modules and plugins. Perhaps in the future we
    will extend to reduce boilerplate code in existing Ansible-related

    PR:             255920
    Reported by:    lcook
    Reviewed by:    madpilot
    Differential Revision:  https://reviews.freebsd.org/D30312

 Mk/Uses/ansible.mk (new) | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)