Skip to content

Commit

Permalink
Merge pull request #225 from bastelfreak/plans
Browse files Browse the repository at this point in the history
Add infra_role_summary plan
  • Loading branch information
Aaronoftheages committed Apr 15, 2024
2 parents f5977ae + 5354de0 commit 793f801
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, [])`

### <a name="pe_status_check--infra_role_summary"></a>`pe_status_check::infra_role_summary`

provides an overview of all *PE* systems and their role

### <a name="pe_status_check--infra_summary"></a>`pe_status_check::infra_summary`

Summary report if the state of pe_status check on each node
Expand Down
23 changes: 23 additions & 0 deletions plans/infra_role_summary.pp
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 793f801

Please sign in to comment.