I know about
puppet agent --disable "my message" --verbose
but I would like to know at some point on a given machine, what is its puppet agent status. I don't see how to do it from
man puppet-agent
Is there an command that would tell me if the agent is enabled or disabled ?
------------------- EDIT
CentOS release 6.6 (Final)
bash-4.1$ puppet --version
3.7.4
bash-4.1$ file /usr/bin/puppet
/usr/bin/puppet: a /usr/bin/ruby script text executable
------------------- EDIT2
Whether it is enabled or disabled, I always get this:
[root@p1al25 ~]# cat `sudo puppet agent --configprint agent_catalog_run_lockfile`
cat: /var/lib/puppet/state/agent_catalog_run.lock: No such file or directory
[root@p1al25 ~]# puppet agent --disable "my message"
[root@p1al25 ~]# cat `sudo puppet agent --configprint agent_catalog_run_lockfile`
cat: /var/lib/puppet/state/agent_catalog_run.lock: No such file or directory
[root@p1al25 ~]# service puppet status
puppet (pid 4387) is running...
------------------- EDIT3
This one worked, thanks daxlerod
[root@p1al25 ~]# service puppet status
puppet (pid 4387) is running...
[root@p1al25 ~]# puppet agent --disable "my message" --verbose
Notice: Disabling Puppet.
[root@p1al25 ~]# cat `puppet agent --configprint agent_disabled_lockfile`
{"disabled_message":"reason not specified"}
A one-liner to get the current status is:
cat `puppet agent --configprint agent_disabled_lockfile`
Generally, this must be run as root, so I use:
sudo cat `sudo puppet agent --configprint agent_disabled_lockfile`
There are a number of possible results.
cat: \path\to\lock: No such file or directory
Puppet is not disabled.puppet agent --disable 'reason'
I thought I'd post here an updated answer.
If the Puppet agent is disabled, there will be a file $vardir/state/agent_disabled.lock
. This file also contains the reasons of the disabling, if a reason has been given via puppet agent --disable 'because reasons'
.
You can get the value of $vardir
via the command puppet config print vardir
.
To sum up:
[me@linuxbox ~]# cat $(puppet config print vardir)/state/agent_disabled.lock
If the agent is disabled, you get:
{"disabled_message":"because reasons"}
If the agent is enabled, you get an error "No such file or directory".
agent status is typically used in a master-slave setup.
More details are here:
https://docs.puppetlabs.com/learning/agent_master_basic.html
since there are two possible questions you could be asking. One being:
Is my service running?
to which the answer would be running your typical service command (for example service puppet status)
Or, is my agent fully able to run?
To which the answer would be to use the command puppet agent --test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With