-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
W.I.P. PR2: New functions created to query for each item - calling of functions in importer.pp #10
Changes from 10 commits
48101d2
de69461
20757fe
89cfb85
abc93c1
bbcc993
d9e9c5b
49f3ed6
8f29421
7ca726d
6ebf3e4
2f0e788
7e6dfb8
41294cd
342737d
3c5b46c
749f73b
fde7a15
e1e7924
063f0c3
f4dec00
92c9917
9856f29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function rsan::get_postgres_hosts() { | ||
if $settings::storeconfigs { | ||
$postgres_hosts = | ||
puppetdb_query('resources[certname] { | ||
type = "Class" and | ||
title = "pe_postgresql::server::install" and | ||
nodes { | ||
deactivated is null and | ||
expired is null | ||
} | ||
}').map |$data| { $data['certname'] } | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as there is no longer a conditional the exception of not having a postgres host returned needs handled differently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey Marty, would this mean I need to implement some sort of error catch? So if puppetdb_query returns nothing/an error - make an exception to set
|
||
$postgres_hosts = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $postgres_hosts would need to be returned in a format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So in this case, puppet_metrics_dashboard::postgres_host would need to be an array of elements, with each element being a postgres host. I've been looking at https://puppet.com/docs/puppet/7.0/lang_data_type.html Initially, part of me thinks that I need to some thing like:
My thinking is that by setting the data type beforehand - puppetdb_query will fill in the elements to that array as appropriate? But I've also come across https://puppet.com/docs/puppet/7.0/lang_data_type.html#lang_data_type_usage Where there is the 'Type' function. In this instance, I would do something like get the data type from the $postgres_hosts after the puppetdb_query is finished, then if the data type of $postgres_hosts =/ array, I set it as so? |
||
} | ||
|
||
pe_sort($postgres_hosts) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function rsan::get_puppet_servers() { | ||
$puppet_servers = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a syntax issue here, best PDK validate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Syntax issue on this should be solved in my next commit from my local repo :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $puppet_servers needs to be in a format puppet_metrics_dashboard::master_list expects |
||
puppetdb_query('nodes[certname] { | ||
resources { | ||
type = "Class" and | ||
title = "Puppet_enterprise::Profile::Master" | ||
} and deactivated is null and expired is null }').map |$node| { | ||
$node['certname'] | ||
} | ||
pe_sort($puppet_servers) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function rsan::get_puppetdb_hosts() { | ||
if $settings::storeconfigs { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comments on the condition here |
||
$puppetdb_hosts = | ||
puppetdb_query('resources[certname] { | ||
type = "Class" and | ||
title = "Puppet_enterprise::Profile::Puppetdb" and | ||
nodes { | ||
deactivated is null and | ||
expired is null | ||
} | ||
}').map |$data| { $data['certname'] } | ||
} else { | ||
$puppetdb_hosts = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. puppetdb_hosts has to be returned in the correct format for puppet_metrics_dashboard::puppetdb_list |
||
} | ||
|
||
pe_sort($puppetdb_hosts) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,16 +20,27 @@ | |
################### 3. Telemetry dashboard ######################################## | ||
# If using puppet_metrics_dashboard: | ||
|
||
# class { 'puppet_metrics_dashboard': | ||
# add_dashboard_examples => true, | ||
# overwrite_dashboards => false, | ||
# configure_telegraf => true, | ||
#enable_telegraf => true, | ||
#master_list => $infranode, | ||
#puppetdb_list => [$pdb], | ||
#postgres_host_list => [$postgres], | ||
|
||
#} | ||
# | ||
# this is where lists of master_list , puppetdb_list, postgres_host_list hosts are found using a puppetdb query | ||
#make sure each list is same format | ||
|
||
#conditions of whether postgres is present or not | ||
|
||
#in the below class | ||
|
||
$puppet_severs = rsan::get_puppet_servers() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we expose these as parameters instead of just declaring as variables? That way someone should be able to call the class like so and override the defaults if they need to: class { 'rsan::importer':
puppet_servers => ['server1.company.com', 'server2.company.com'],
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So in this instance, I'd be looking to do something like:
Is that right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well that's what the user would do when the use RSAN. In order for you to allow them to do that you'll need to allow the class rsan::importer (
String $some_param = "hello",
) { |
||
$puppetdb_hosts = rsan::get_puppetdb_hosts() | ||
$postgres_hosts = rsan::get_postgres_hosts() | ||
|
||
class { 'puppet_metrics_dashboard': | ||
add_dashboard_examples => true, | ||
overwrite_dashboards => false, | ||
configure_telegraf => true, | ||
enable_telegraf => true, | ||
master_list => $puppet_servers, | ||
puppetdb_list => $puppetdb_hosts, | ||
postgres_host_list => $postgres_hosts, | ||
} | ||
|
||
# master_list , puppetdb_list, postgres_host_list need to be queried from the system programatically | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes this whole thing conditional on $settings::storeconfigs, which is a snippet from another place in code this was copied from. This does not need to be conditional