Add configurable path for Redis/Gateway build temp directories - #373
Open
mazam32-itential wants to merge 1 commit into
Open
Add configurable path for Redis/Gateway build temp directories#373mazam32-itential wants to merge 1 commit into
mazam32-itential wants to merge 1 commit into
Conversation
ansible.builtin.tempfile does not honor remote_tmp/ansible_remote_tmp.
On hosts where /tmp is mounted noexec, the Redis source build's
configure/make steps fail with "Permission denied" since they need to
execute files from that directory. Add an optional path for each
role's build/staging tempfile task (redis_build_temp_dir_path,
gateway_build_temp_dir_path), sourced via `| default(omit)` rather
than a literal default so that when unset, the path argument is
omitted entirely and the module falls back to its own normal
directory resolution (TMPDIR/TEMP/TMP env vars, then /tmp, /var/tmp,
/usr/tmp) - identical behavior to before this change, with no gap for
hosts that happen to have a non-default TMPDIR set for root.
Tested against a live EC2 instance (Rocky Linux 9):
- Baseline (no override set): confirmed via -v output that the
tempfile task's path resolved through the default(omit) fallback,
landing on /tmp as before; Redis 7.4.6 built and installed
successfully.
- Negative test: created a real noexec tmpfs mount
(mount -t tmpfs -o noexec /mnt/noexec-test), forced a Redis rebuild,
and set redis_build_temp_dir_path to that mount. The build failed
exactly as reported:
"sh: line 1: ./mkreleasehdr.sh: Permission denied"
"/bin/sh: line 1: ./configure: Permission denied"
- Positive test: same setup, redis_build_temp_dir_path set to
/var/tmp instead. Build succeeded, confirming the override actually
fixes the reported failure.
- Ran the full Gateway install with gateway_build_temp_dir_path
pointed at the same noexec mount: it succeeded end-to-end
(failed=0, automation-gateway.service active). Gateway's `pip
install` only reads the staged .whl file rather than executing
anything from that directory, so it was never actually vulnerable to
this failure mode - its variable is added for the same configurable
control the ticket asked for, not because a real bug was reproduced
there.
- ansible-lint on all four changed task/doc files passes clean
(0 failures; pre-existing unrelated warnings elsewhere unchanged).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ansible.builtin.tempfiledoes not honorremote_tmp/ansible_remote_tmp. On hosts where/tmpis mountednoexec, the Redis source build'sconfigure/makesteps fail with "Permission denied" since they need to execute files from that directory.pathfor each role's build/stagingtempfiletask:redis_build_temp_dir_pathandgateway_build_temp_dir_path.| default(omit)rather than a literal/tmpdefault, so when unset thepathargument is omitted entirely and the module falls back to its own normal directory resolution (TMPDIR/TEMP/TMPenv vars, then/tmp,/var/tmp,/usr/tmp) — identical behavior to before this change, including for any host that happens to have a non-defaultTMPDIRset for root.roles/redis/CLAUDE.md/docs/redis_guide.mdandroles/gateway/CLAUDE.md/docs/itential_gateway_guide.md.How this was tested
Tested against a live EC2 instance (Rocky Linux 9):
Baseline (no override set): confirmed via
-voutput that the tempfile task'spathresolved through thedefault(omit)fallback, landing on/tmpas before. Redis 7.4.6 built and installed successfully.Negative test: created a real
noexectmpfs mount (mount -t tmpfs -o noexec,size=200M tmpfs /mnt/noexec-test), forced a Redis rebuild, and setredis_build_temp_dir_pathto that mount. The build failed exactly as reported:Positive test: same setup,
redis_build_temp_dir_pathset to/var/tmpinstead. Build succeeded, confirming the override fixes the reported failure.Gateway: ran the full Gateway install with
gateway_build_temp_dir_pathpointed at the samenoexecmount — it succeeded end-to-end (failed=0,automation-gateway.serviceactive). Gateway'spip installonly reads the staged.whlfile rather than executing anything from that directory, so it was never actually vulnerable to this failure mode. Its variable is added for the same configurable control, not because a reproducible bug exists there — flagging this explicitly rather than implying an equivalent fix.Lint:
ansible-linton all changed task/doc files passes clean (0 failures; pre-existing unrelated warnings elsewhere unchanged).Test plan for reviewer