Determine puppet agents using capsule as puppet master

Latest response

Is there a way to query either satellite via hammer CLI or the puppet master itself (i.e. the capsule) to determine which hosts are using that capsule as a puppet master?

We have 13 capsules all setup as puppet masters and have static configuration pointing to them, but we have 3,000 hosts and it would be easier to query the master or satellite and sort a CSV to determine the lists for when we migrate to 6.2.8 from 6.1.7

Thanks

Responses

See

hammer host list --search 'smart_proxy = capsule-1.example.com' 
----|---------------------------|------------------|------------|-------------|------------------
ID  | NAME                      | OPERATING SYSTEM | HOST GROUP | IP          | MAC              
----|---------------------------|------------------|------------|-------------|------------------
101 | capsule-1.example.com     | RedHat 7.3       |            | 172.17.0.22 | b8:ae:ed:7d:0d:cb
101 | client-12.example.com     | RedHat 7.3       | RHEL7/DEV  | 172.17.0.24 | b8:ae:ed:7d:0d:ca
----|---------------------------|------------------|------------|-------------|------------------

That will show you 'for the specified capsule, show me any clients that are using it as a proxy', be that for Puppet, Puppet CA, etc.

Unless you have a configuration where you have clients using services from more than one capsule (such as Puppet from one capsule, and PuppetCA from another), the above will be accurate. And you can use hammer --output csv to get that data in CSV format (or JSON or YAML if you prefer those formats)

Just to add to Rich's comments, if you want to cycle through all Capsules using Puppet Muster and list their hosts, you can use the hammer host list command after iterating through the Puppet Master Capsules using the hammer capsule list command:

for CAPSULE in $(hammer --csv capsule list --search "feature = Puppet" | sed '1d' | cut -d ',' -f2) ; do echo "== Hosts using $CAPSULE ==" ; hammer host list --search "smart_proxy = $CAPSULE" ; done

And if you wanted to make one big CSV file:

for CAPSULE in $(hammer --csv capsule list --search "feature = Puppet" | sed '1d' | cut -d ',' -f2) ; do hammer --csv host list --search "smart_proxy = $CAPSULE" | sed '1d' | awk -F"," "BEGIN { OFS = \",\" } {\$6=\"$CAPSULE\"; print}" >> hosts-puppet_masters.csv ; done

This will create a file called hosts-puppet_masters.csv that contains a list of all hosts using Puppet Master Capsules and specifies which Puppet Master they're using.

If you need to regenerate this file, make sure to manually delete it first or else the command will just append to the end of the file.

Also note that this command does not include hosts that aren't using a Puppet Master Capsule.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.