Bug 265211 - sysutils/ansible 2.13 now expects shebang format in moudles
Summary: sysutils/ansible 2.13 now expects shebang format in moudles
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Mateusz Piotrowski
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-14 14:44 UTC by vladimir-csp
Modified: 2022-07-21 23:48 UTC (History)
3 users (show)

See Also:
0mp: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vladimir-csp 2022-07-14 14:44:07 UTC
Hi.
2.13 broke deployment from FreeBSD control host to Linux target hosts because it now can modify shebangs in modules and expects them to be either unversioned or absent.
At least some (if not all) modules in py38-ansible package have versioned python shebangs (modules from ansible-core do not have any), those modules now fail.

More info here:

https://github.com/ansible/ansible/issues/78243

Breaking change is here: https://github.com/ansible/ansible/issues/78243
Comment 1 vladimir-csp 2022-07-14 14:45:31 UTC
Wrong link on breaking change, here https://github.com/ansible/ansible/pull/76677
Comment 2 May Gatliff 2022-07-20 05:44:03 UTC
I have not been able to reproduce this bug
Comment 3 vladimir-csp 2022-07-20 11:38:29 UTC
(In reply to May Gatliff from comment #2)

Do you by any chance have python on target host by the same path as in modules' tampered shebang?
Comment 4 Bjarne 2022-07-20 12:30:46 UTC
I can confirm this. 
Playbooks only works against FreeBSD clients.
Centos,Rocky OpenSuse all fails.
Rolling back on the controller to py39-ansible-core-2.12.7 fixes this, as well as the described fix in https://github.com/ansible/ansible/issues/78243 to set environment variable: ansible_python3.9_interpreter: /usr/bin/python3.9 

The ansible controller assumes /usr/local/bin/python3.9 on all platforms.
Comment 5 vladimir-csp 2022-07-20 13:27:23 UTC
Tried replacing SHEBANG_GLOB with:

SHEBANG_REGEX=	(([^/])|(/[^m])|(/m[^o])|(/mo[^d])|(/mod[^u])|(/modu[^l])|(/modul[^e])|(/module[^s])|(/modules[^/]))*\.(py|sh|build.py.generic)

(excluding anything with /modules/ in path)
(not having negative lookahead is a pain).

Seems to be working.
Comment 6 Mateusz Piotrowski freebsd_committer freebsd_triage 2022-07-21 23:36:29 UTC
Thanks a lot for the report. I'm testing the SHEBANG_REGEX now.
Comment 7 commit-hook freebsd_committer freebsd_triage 2022-07-21 23:47:10 UTC
A commit in branch main references this bug:

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

commit a6edc54ae6911d8d7621182c2c2ffa26777985ea
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2022-07-21 23:38:56 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2022-07-21 23:45:15 +0000

    sysutils/ansible: Do not replace shebangs within modules

    It turns out that Ansible does not like when we replace the shebang
    lines with a path to a Python interpreter with a trailing number
    (like "python3.9").

    Stop replacing the shebang lines in modules directories. If it turns out
    to be problematic as well, we may consider introducing an indirect
    symlink to the versioned Python interpreter from a path like
    /usr/local/libexec/ansible/bin/python for example.

    PR:             265211
    Reported by:    vladimir-csp@yandex.ru

 sysutils/ansible/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Comment 8 Mateusz Piotrowski freebsd_committer freebsd_triage 2022-07-21 23:48:10 UTC
Thanks for the SHEBANG_REGEX suggestion.

Please let me know if the problem persist after the update.