Created attachment 207758 [details] port diff Ansible module to manipulate rc.conf on a FreeBSD system via sysrc. The current states available are: append, absent, present and subtract.
WWW: https://github.com/dlundgren/ansible-freebsd-modules/
Thank you for contributing a new port Lewis Note: 'ansible' (the binary) only exists for the default (Python) version of the Ansible port, which may not be the Python version with which this and other ansible module ports may be build with by the user. Use RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}ansible>0:sysutils/ansible@${PY_FLAVOR} instead.
(In reply to Kubilay Kocak from comment #2) Oops! Sorry about that. I'll update the diff now, and the port I submitted earlier too (ansible-kld). Cheers!
Created attachment 207760 [details] port diff fixed Replaced RUN_DEPENDS with the updated value as requested.
Thanks Lewis! A couple more things: - ansible-config needs to be the Python-version specific binary: ansible-config-PYTHON_VER - One should be able to use PYTHON_PKGNAMEPREFIX instead of py[0-9]{2} in the ANSIBLE_MOD line. Please do the same for bug 240789 and future ansible module ports
(In reply to Kubilay Kocak from comment #5) Thanks for your suggestions. I've applied the changes as said, although I'm facing this following error: https://s.wired.sh/~vulcan/uoAyITBhaPAjjulyOiqb. Either I've typed something incorrectly, or there's something else going on. Here's what I've done: - svn checkout head to /usr/ports; - Add the port and attempt to build the package; - That error gets thrown. I have a feeling this a simple fix, or that I'm missing out on something. Thanks for your time.
Created attachment 207762 [details] port diff fix(?)
(In reply to Lewis Cook from comment #6) The error indicates that PYTHON_PKGNAMEPREFIX wasn't being prefixed to 'ansible' in the RUN_DEPENDS line, but the latest diff looks ok. Was the "fix(?) patch produced to fix the error, or is that the version *with* the error? Also, while we're here, we're going to need to PKGNAMEPREFIX=PYTHON_PKGNAMEPREFIX to the port too, as it will be built for/with a specific Python version Same in bug 40789 too The best way to do ports QA is with portlint/poudriere, see: https://www.freebsd.org/doc/en/books/porters-handbook/testing.html
Same in bug 240789 rather Also: PYTHON_PKGNAMEPREFIX already contains a '-' character, so - is not needed in the ANSIBLE_MOD line
(In reply to Kubilay Kocak from comment #8) The patch I submitted was *with* the error. I'll also add the PKGNAMEPREFIX and remove the trailing '-' now.
Created attachment 207763 [details] port diff Are you able to reproduce any errors from this patch?
About to reflect these changes in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240789 too.
(In reply to Kubilay Kocak from comment #9) Managed to quickly setup poudriere on a server. Started the build process which yielded the results: > [00:00:02] Warning: (sysutils/ansible-kld): Error: sysutils/ansible-kld has dependency on sysutils/ansible with invalid empty FLAVOR; Please contact maintainer of the port to fix this. > [00:00:02] Warning: (sysutils/ansible-sysrc): Error: sysutils/ansible-sysrc has dependency on sysutils/ansible with invalid empty FLAVOR; Please contact maintainer of the port to fix this. Turns out, the whole reasoning earlier for the error is because of a one line fix: > USES=python Which would then define the values for PY_FLAVOR which was previously undefined. I'm 99.9% sure that this is the issue, and if such is the case I'll submit the patches for ansible-kld and ansible-sysrc and go from there, just wanted to confirm this with you. Thanks! I cant say I've created a python port before so I'm a little rusty in this area. :)
Created attachment 207779 [details] port diff final Added 'USES=python' in the Makefile, fixing the undefined 'PY_FLAVOR' error when building.
Bump
Hi. I've tried building this port on Poudriere, and the ANSIBLE_MOD/PLIST_FILES lines fail: =======================<phase: stage >============================ ===> Staging for py36-ansible-sysrc-0.1 ===> py36-ansible-sysrc-0.1 depends on package: py36-ansible>0 - found ===> py36-ansible-sysrc-0.1 depends on file: /usr/local/bin/python3.6 - found ===> Generating temporary packing list Unhandled error: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 77, in makedirs_safe os.makedirs(b_rpath, mode) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 523, in update_config_data value, origin = self.get_config_value_and_origin(config, configfile) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 467, in get_config_value_and_origin value = ensure_type(value, defs[config].get('type'), origin=origin) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 110, in ensure_type makedirs_safe(value, 0o700) File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 82, in makedirs_safe raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e))) ansible.errors.AnsibleError: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 77, in makedirs_safe os.makedirs(b_rpath, mode) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 523, in update_config_data value, origin = self.get_config_value_and_origin(config, configfile) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 467, in get_config_value_and_origin value = ensure_type(value, defs[config].get('type'), origin=origin) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 110, in ensure_type makedirs_safe(value, 0o700) File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 82, in makedirs_safe raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e))) ansible.errors.AnsibleError: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/bin/ansible-config-3.6", line 60, in <module> import ansible.constants as C File "/usr/local/lib/python3.6/site-packages/ansible/constants.py", line 189, in <module> config = ConfigManager() File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 263, in __init__ self.update_config_data() File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 535, in update_config_data raise AnsibleError("Invalid settings supplied for %s: %s\n" % (config, to_native(e)), orig_exc=e) ansible.errors.AnsibleError: Invalid settings supplied for DEFAULT_LOCAL_TMP: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' /bin/mkdir -p /wrkdirs/usr/ports/sysutils/ansible-sysrc/work/stage$(ansible-config-3.6 dump | /usr/bin/egrep -o '/usr/local/share/py36-ansible/plugins/modules') Unhandled error: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 77, in makedirs_safe os.makedirs(b_rpath, mode) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 523, in update_config_data value, origin = self.get_config_value_and_origin(config, configfile) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 467, in get_config_value_and_origin value = ensure_type(value, defs[config].get('type'), origin=origin) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 110, in ensure_type makedirs_safe(value, 0o700) File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 82, in makedirs_safe raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e))) ansible.errors.AnsibleError: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 77, in makedirs_safe os.makedirs(b_rpath, mode) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 523, in update_config_data value, origin = self.get_config_value_and_origin(config, configfile) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 467, in get_config_value_and_origin value = ensure_type(value, defs[config].get('type'), origin=origin) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 110, in ensure_type makedirs_safe(value, 0o700) File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 82, in makedirs_safe raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e))) ansible.errors.AnsibleError: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/bin/ansible-config-3.6", line 60, in <module> import ansible.constants as C File "/usr/local/lib/python3.6/site-packages/ansible/constants.py", line 189, in <module> config = ConfigManager() File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 263, in __init__ self.update_config_data() File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 535, in update_config_data raise AnsibleError("Invalid settings supplied for %s: %s\n" % (config, to_native(e)), orig_exc=e) ansible.errors.AnsibleError: Invalid settings supplied for DEFAULT_LOCAL_TMP: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' install -m 555 /wrkdirs/usr/ports/sysutils/ansible-sysrc/work/ansible-freebsd-modules-cf37fc1e16fc03852abc8933e7959b22b51a5c90/library/sysrc /wrkdirs/usr/ports/sysutils/ansible-sysrc/work/stage$(ansible-config-3.6 dump | /usr/bin/egrep -o '/usr/local/share/py36-ansible/plugins/modules')/sysrc Unhandled error: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 77, in makedirs_safe os.makedirs(b_rpath, mode) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 523, in update_config_data value, origin = self.get_config_value_and_origin(config, configfile) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 467, in get_config_value_and_origin value = ensure_type(value, defs[config].get('type'), origin=origin) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 110, in ensure_type makedirs_safe(value, 0o700) File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 82, in makedirs_safe raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e))) ansible.errors.AnsibleError: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 77, in makedirs_safe os.makedirs(b_rpath, mode) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/usr/local/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 523, in update_config_data value, origin = self.get_config_value_and_origin(config, configfile) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 467, in get_config_value_and_origin value = ensure_type(value, defs[config].get('type'), origin=origin) File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 110, in ensure_type makedirs_safe(value, 0o700) File "/usr/local/lib/python3.6/site-packages/ansible/utils/path.py", line 82, in makedirs_safe raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e))) ansible.errors.AnsibleError: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/bin/ansible-config-3.6", line 60, in <module> import ansible.constants as C File "/usr/local/lib/python3.6/site-packages/ansible/constants.py", line 189, in <module> config = ConfigManager() File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 263, in __init__ self.update_config_data() File "/usr/local/lib/python3.6/site-packages/ansible/config/manager.py", line 535, in update_config_data raise AnsibleError("Invalid settings supplied for %s: %s\n" % (config, to_native(e)), orig_exc=e) ansible.errors.AnsibleError: Invalid settings supplied for DEFAULT_LOCAL_TMP: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent' Switching to USES_PYTHON=autoplist, it fails with: ===> Generating temporary packing list /bin/mkdir -p /wrkdirs/usr/ports/sysutils/ansible-sysrc/work/stage install -m 555 /wrkdirs/usr/ports/sysutils/ansible-sysrc/work/ansible-freebsd-modules-cf37fc1e16fc03852abc8933e7959b22b51a5c90/library/sysrc /wrkdirs/usr/ports/sysutils/ansible-sysrc/work/stage/sysrc ====> Compressing man pages (compress-man) =========================================================================== ====> Running Q/A tests (stage-qa) ====> Checking for pkg-plist issues (check-plist) ===> Parsing plist ===> Checking for items in STAGEDIR missing from pkg-plist Error: Orphaned: /sysrc ===> Checking for items in pkg-plist which are not in STAGEDIR ===> Error: Plist issues found. *** Error code 1
(In reply to Raphael Kubo da Costa from comment #16) Thanks for your report. That's odd. I don't think the problem stems from the port itself, but rather the value of 'DEFAULT_LOCAL_TMP' as it doesn't seem to have permission to write to the directory, referring to the error below: Unable to create local directories(/nonexistent/.ansible/tmp): [Errno 13] Permission denied: b'/nonexistent'. I'm unable to reproduce this error within Poudriere or on my local machine too. When running stage-qa I was prompted to add the shebang fix: ====> Running Q/A tests (stage-qa) Error: '/usr/bin/python' is an invalid shebang you need USES=shebangfix for 'share/py36-ansible/plugins/modules/sysrc'. Which I have now reflected in the Makefile, now it doesn't use a hard-coded path to Python in the sysrc Ansible module, instead patched with the Python version used to build the port. Upon making this change I no longer am prompted with changes to be made. 'USES_PYTHON=autoplist' I believe isn't _needed_ either in this particular case as PLIST_FILES will resolve the 'sysrc' module. Which is more than likely causing the stage-qa error. From what I've extrapolated from the errors posted it's more of a permission issue and the inability to write to the value of 'DEFAULT_LOCAL_TMP' in the Ansible configuration. Cheers. * On another note, replaced ${EGREP} with ${GREP} as extended regex isn't necessary. Also have formatted the Makefile with portfmt.
Created attachment 208820 [details] updated
Followed up these changes in bug #240814 and bug #240789.
I got the same "PermissionError: [Errno 13] Permission denied: b'/nonexistent'" errors in Poudriere when testing the latest version of the patch. FTR, I'm using "poudriere testport" to test this. Since the port's installing just on file, isn't it easier to just have ANSIBLE_MOD= ${PREFIX}/share/${PYTHON_PKGNAMEPREFIX}ansible/plugins/modules instead of invoking ansible-config and grepping for a value you already have?
(In reply to Raphael Kubo da Costa from comment #20) I created a new fresh environment for the build, then ran: > poudriere testport -j builder-amd64 -p devel -c sysutils/ansible-sysrc And was still unable to reproduce the error you've been facing. For the build logs, see here: https://s.wired.sh/~vulcan/log/py36-ansible-sysrc-0.1.log — which leads me to believe there's something not quite right in your jail build environment. Also, made the amendment of ANSIBLE_MOD. Didn't seem to catch that, cheers! (I'll again forward the changes to bug #240814 and bug #240789). :)
Created attachment 208827 [details] port diff * Amended ANSIBLE_MOD, remove un-needed call to 'ansible-config'.
Comment on attachment 208827 [details] port diff Removing the call to ansible-config finally made the port build fine here. The difference could be that I'm using poudriere-devel, but other than that I'm just invoking `poudriere testport -p default -j 13amd64 -i -o sysutils/ansible-sysrc' and have DEVELOPER_MODE=yes in make.conf. As for the patch, one thing that can still be improved: +ANSIBLE_MOD= ${PREFIX}/share/${PYTHON_PKGNAMEPREFIX}ansible/plugins/modules + +PLIST_FILES= $$(${ECHO_CMD} ${ANSIBLE_MOD} | ${SED} -e 's|${PREFIX}/||')/sysrc The echo+sed combination is unnecessary, remember you're setting ANSIBLE_MOD yourself. My suggestion is to do something like ANSIBLE_MOD_REL= share/${PYTHON_PKGNAMEPREFIX}ansible/plugins/modules PLIST_FILES= ${ANSIBLE_MOD_REL}/sysrc do-install: [...] ${INSTALL_SCRIPT} ${WRKSRC}/library/sysrc ${STAGEDIR}${PREFIX}/${ANSIBLE_MOD_REL}/sysrc
(In reply to Raphael Kubo da Costa from comment #23) Glad that's been resolved. Thanks for the guidance, I'll take this into account with any further port submissions. Will make these changes in this port as well as bug #240814 and bug #240789. Cheers!
Created attachment 208857 [details] port diff * Further revision of Makefile as suggested.
A commit references this bug: Author: rakuco Date: Mon Nov 4 20:21:01 UTC 2019 New revision: 516737 URL: https://svnweb.freebsd.org/changeset/ports/516737 Log: New port: sysutils/ansible-sysrc Ansible module to manipulate rc.conf on a FreeBSD system via sysrc. The current states available are: append, absent, present and subtract. PR: 240788 Submitted by: Lewis Cook <vulcan@wired.sh> Changes: head/sysutils/Makefile head/sysutils/ansible-sysrc/ head/sysutils/ansible-sysrc/Makefile head/sysutils/ansible-sysrc/distinfo head/sysutils/ansible-sysrc/pkg-descr
Thank you!
Awesome. Cheers!