Open zbentley opened 7 months ago
This issue may also manifest as "err: sh: 1: /tmp/c70bfc00-15cc-4d00-8995-af728e5deae1/custom_facts.rb: not found" on Ubuntu. In my case I am trying to deploy to ubuntu 24.04 server, which I have installed puppet via apt.
The error message is confusing since the file does exist, but it is because just like you found with installing via pacman, apt does not install to /opt/
so there is no /opt/puppetlabs/puppet/bin/ruby
.
Describe the Bug
If I install the Puppet agent on a target using its system package manager, the Puppet package may not be placed in "/opt/puppetlabs", which causes
bolt apply
to fail.While most of the "first-class" supported targets (e.g. debian) have puppet installation packages that work correctly, many distros (e.g. Arch) do not.
Expected Behavior
If puppet/facter/etc. are present and usable on a Linux target via an official package installed via the system package manager,
bolt apply
should not fail.Steps to Reproduce
pacman -S puppet
.bolt apply --targets arch --log-level debug --execute 'notify{"hello world":;}'
Environment
Additional Context
I know that Arch isn't a first-class Puppet/Bolt supported environment, and that there are many parts of Bolt and some Bolt modules that have strong opinions about Puppet being installed into
/opt/puppetlabs
.This issue is not trying to change that; Bolt itself, and Puppet distributions installed on many platforms are free to insist on
/opt/puppetlabs
paths for their components.However, specifically for Ruby scripts invoked by Bolt at the "bootstrap" phase (e.g. custom_facts.rb), I think that Bolt shouldn't care where/how Puppet is installed on the target: Bolt should be able to invoke Puppet as it is installed on the target host, without insisting on
/opt/puppetlabs
.Specifically, the below files look like their shebangs should be updated to be location-agnostic for Puppet (the below contains my search for the problematic shebang in files that could be invoked by Bolt on the target, rather than parts of Bolt itself).
Suggested Fix
When invoking those scripts, Bolt may choose to set up
PATH
such that/opt/puppetlabs/bin
is preferred over other locations (to increase predictability in the face of multiple Puppet installs, which seems unusual), but it should not hardcode the/opt/puppetlabs/bin
shebang; doing so needlessly harms compatibility with non-first-class target distributions.In fact, Bolt already does this in one place,
libexec/bolt_catalog
; that's just not sufficient to makebolt apply
work in its entirety.