puppetlabs / puppetlabs-pe_status_check

Self Service Module for Puppet Enterprise
Apache License 2.0
1 stars 33 forks source link

(SUP-3121) Agent connection to pxp broker #106

Closed MartyEwings closed 2 years ago

MartyEwings commented 2 years ago

This Commit adds AS002 -

Determines if the pxp-agent has an established connection to a pxp broker

. This fact can also be used as a target filter for running tasks, ensuring time is not wasted sending instructions to agents not connected to a broker

m0dular commented 2 years ago

Did @jarretlavallee leave a comment earlier about using Facter::Core::Execution.execute(), or am I imagining that?

jarretlavallee commented 2 years ago

I did, but I am not sure where it went. The main thing is just to rescue the exception thrown so it doesn't show a failure. Facter::Core::Execution.execute makes that easy and standardizes the shell calls.

MartyEwings commented 2 years ago

@jarretlavallee @m0dular I switched to facter core, it captures the exception by default, i didn't see any value it it returning a string, because true or false would be mis leading if its not able to determine it

jarretlavallee commented 2 years ago

Facter::Core::Execution.execute will raise a Facter::Core::Execution::ExecutionFailure on failure by default. The :on_fail option can be used, but you would have to parse the string to see that failure.

MartyEwings commented 2 years ago

@jarretlavallee @m0dular this what you mean? it give the following output if execution fails

[root@pe-node-c17718-1 user]# mv /sbin/ss /tmp/
[root@pe-node-c17718-1 user]# facter -p agent_status_check
[2022-04-04 16:39:49.397300 ] WARN Facter - pe_status_check.AS002 failed to get socket status
{
  AS001 => true,
  AS002 => false
}