diff --git a/README.md b/README.md index 2fac0ef7..f39638e1 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,32 @@ The plans, `pe_status_check::infra_summary` and `pe_status_check::agent_summary` } ``` +The plan `pe_status_check::infra_role_summary` will provide you a hash with all PE infrastructure nodes, grouped by their role: + +```json +{ + "primary": [ + "primary.bastelfreak.local" + ], + "replica": [ + "replica.bastelfreak.local" + ], + "compiler": [ + "compiler01.bastelfreak.local", + "compiler02.bastelfreak.local" + ], + "postgres": [], + "legacy_primary": [], + "legacy_compiler": [] +} +``` + +The data is obtained from PuppetDB by checking the classes in the last catalog +of every node. You can reuse the data in other plans or use it to inspect your +environment. You can plott it in a more human-readable way with the +[puppet/format](https://github.com/voxpupuli/puppet-format?tab=readme-ov-file#puppet-format) +modules. + ### Using a Puppet Query to report status. As the pe_status_check module uses Puppet's existing fact behavior to gather the status data from each of the agents, it is possible to use PQL (puppet query language) to gather this information. diff --git a/REFERENCE.md b/REFERENCE.md index a5e6b160..7e8067c0 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -14,6 +14,7 @@ * [`pe_status_check::agent_summary`](#pe_status_check--agent_summary): Summary report of the state of agent_status_check on each node Uses the facts task to get the current status from each node and produces a summary report in JSON +* [`pe_status_check::infra_role_summary`](#pe_status_check--infra_role_summary): provides an overview of all *PE* systems and their role * [`pe_status_check::infra_summary`](#pe_status_check--infra_summary): Summary report if the state of pe_status check on each node Uses the facts task to get the current status from each node and produces a summary report in JSON @@ -114,6 +115,10 @@ Static Hiera Data can be used to set indicator_exclusions in a plan - for more i Default value: `lookup('pe_status_check::indicator_exclusions', undef, undef, [])` +### `pe_status_check::infra_role_summary` + +provides an overview of all *PE* systems and their role + ### `pe_status_check::infra_summary` Summary report if the state of pe_status check on each node diff --git a/plans/infra_role_summary.pp b/plans/infra_role_summary.pp new file mode 100644 index 00000000..ae78dd61 --- /dev/null +++ b/plans/infra_role_summary.pp @@ -0,0 +1,23 @@ +# +# @summary provides an overview of all *PE* systems and their role +# +plan pe_status_check::infra_role_summary { + # this provides similar data as the pe_status_check_role fact. But the fact + # isn't a secure source, because that's node-supplied data and they could fake it. + $primary = puppetdb_query('resources[certname] { type = "Class" and title in [ "Puppet_enterprise::Profile::Certificate_authority", "Puppet_enterprise::Profile::Database"] group by certname }').map |$fqdn| { $fqdn['certname'] } + $legacy_primary = puppetdb_query('resources[certname] { type = "Class" and title = "Puppet_enterprise::Profile::Certificate_authority" group by certname }').map |$fqdn| { $fqdn['certname'] } - $primary + $replica = puppetdb_query('resources[certname] { type = "Class" and title = "Puppet_enterprise::Profile::Primary_master_replica" group by certname }').map |$fqdn| { $fqdn['certname'] } + $compiler = puppetdb_query('resources[certname] { type = "Class" and title in [ "Puppet_enterprise::Profile::Master", "Puppet_enterprise::Profile::Puppetdb"] group by certname }').map |$fqdn| { $fqdn['certname'] } - $primary + $legacy_compiler = puppetdb_query('resources[certname] { type = "Class" and title = "Puppet_enterprise::Profile::Master" group by certname }').map |$fqdn| { $fqdn['certname'] } - $compiler - $primary + $postgres = puppetdb_query('resources[certname] { type = "Class" and title = "Puppet_enterprise::Profile::Database" group by certname }').map |$fqdn| { $fqdn['certname'] } - $primary + + $data = { + 'primary' => $primary, + 'legacy_primary' => $legacy_primary, + 'replica' => $replica, + 'compiler' => $compiler, + 'legacy_compiler' => $legacy_compiler, + 'postgres' => $postgres, + } + return $data +}