-
-
Save bastelfreak/b9620fa1892ebcc659c442b115db34f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class profiles::nfscluster { | |
# query the puppetdb in an overly complicated way to get the certname of the other cluster member | |
# this query honours our test/prod environment. it will break as soon as we've three or more nodes in one environment | |
# https://puppet.com/docs/puppet/5.5/function.html#map | |
# https://puppet.com/docs/puppet/5.5/function.html#filter | |
# https://puppet.com/docs/puppetdb/5.1/api/query/v4/ast.html#summary | |
# https://puppet.com/docs/puppetdb/5.1/api/query/tutorial.html#how-to-query | |
$nfs_cluster_nodes_query =['from', 'facts', ['and', | |
['=', 'name', 'hostname'], | |
['in', 'certname', | |
['extract', 'certname', ['select_facts', | |
['and', | |
['=', ['fact', 'role'], $facts['role']], | |
['=', ['fact', 'type'], $facts['type']]]]]]]] | |
$nodes = puppetdb_query($nfs_cluster_nodes_query) | |
$node = $nodes.map |$node| { | |
{ 'fqdn' => $node['certname'], 'hostname' => $node['value'] } | |
}.filter |$node| { | |
$node['fqdn'] != $trusted['certname'] | |
}[0] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment