Weird problem with a custom fact. Exact same cod...
# puppet
a
Weird problem with a custom fact. Exact same code in 2 different environments for a custom fact. In EnvA, calling the wrapper.sh script or /opt/puppetlabs/puppet/bin/puppet works as expected. In EnvB, calling the wrapper script works, but calling the puppet binary directly fails to load/find the custom fact. Thoughts?
c
calling the puppet binary directly
What is the path to the binary you are using in that call?
a
Same path I posted in EnvA.
c
Does
/opt/puppetlabs/bin/puppet
work in EnvB? That calls through the wrapper script, which is how all calls to
puppet
should be made.
a
Every path that exists in EnvA exists in EnvB, exactly the same. Symlinks, wrapper.sh code, and all.
c
You noted "In EnvB, calling the wrapper script works". That is what
/opt/puppetlabs/bin/puppet
does, so it should work as well (note, this is a subtly different path from
/opt/puppetlabs/puppet/bin/puppet
).
a
Yeah. I even tried commenting out everything in that file except the last 2 commands. Still worked as expected in both environments.
I’m on my phone, so it’s a pain to type.
c
Ok, I'm confused as to what the issue is then. Sounds like calls to
puppet
that go through the wrapper script are working, and all calls to
puppet
should go through the wrapper script.
That is: if you have something that is trying to call
puppet
up by running
/opt/puppetlabs/puppet/bin/puppet
, that should be changed to use
/opt/puppetlabs/bin/puppet
a
I’m confused on why bypassing the wrapper script works on EnvA but fails on EnvB. All other things except the Environment being equal.
Should also add that running Puppet via the PE Web Console also fails to grab the custom fact in EnvB.
Running it that way appears to bypass the wrapper script also.
c
Yeah, I think the
pxp-agent
service starts its binary directly. What does the follow produce for one of the agent nodes that does not report the fact to the Web Console?
Copy code
cat /proc/$(systemctl show -P MainPID pxp-agent)/environ |tr '\0' '\n'
a
Same values between environments, just the INVOCATION_ID and JOURNAL_STREAM values differ.
c
But, what values are set? Particularly, anything that the wrapper script would scrub?
a
Aside from the above 2, PATH and LANG. Path from pxp-agent environ has in the following order: /usr/local/sbin, /usr/local/bin, /usr/sbin, and /usr/bin Path from wrapper.sh after changes includes the above, with /opt/puppetlabs/bin tacked onto the end.
Are invoc and journal values important?
c
Shouldn't be. As far as I know, those are bits of SystemD plumbing that should be there.
a
Also, I want to amend my original statement. It is not actually working as expected in EnvA. Puppet wasn’t failing there because of a fall back specific to EnvA. So, it’s just wrapper.sh vs pxp-agent difference, assuming bypassing wrapper.sh on server directly essentially works the same as the pxp-agent call from PE Web Console.
Issue was entirely my fault for not yet comprehending how to use the facter ruby module.
c
Ah, what implementation detail was leading to the missing fact?
a
Expecting ENV[‘someVar’] to exist when bypassing wrapper.sh. When I realized EnvA wasn’t actually working but falling back to something else in Hiera, I realized all the legacy code I inherited that used that statement wasn’t actually working either…
c
Ah,
someVar
would generally be left alone by
wrapper.sh
unless it was one of the environment options that sets load paths for libraries. BUT, SystemD usually applies heavy sanitization to the environment it gives services. So, the variables available to
puppet
and
pxp-agent
will be very different from what gets set in a login shell.
a
Yeap.