Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the puppet agent status on the machine?

Tags:

puppet

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 ?

Thank you.

-

------------------- 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"}
like image 793
Bob Yoplait Avatar asked Mar 30 '15 15:03

Bob Yoplait


3 Answers

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.
  • Any other text means that puppet is disabled, and the text is the reason provided when puppet was disabled by puppet agent --disable 'reason'
like image 108
daxlerod Avatar answered Nov 09 '22 17:11

daxlerod


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".

like image 24
dr_ Avatar answered Nov 09 '22 16:11

dr_


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

like image 1
KirstensAmazing Avatar answered Nov 09 '22 15:11

KirstensAmazing