Skip to content

Commit

Permalink
Correctly handle undef name/discovery tag for etcd
Browse files Browse the repository at this point in the history
  • Loading branch information
ananace committed Jan 16, 2025
1 parent d416a02 commit 351a15f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 9 additions & 3 deletions manifests/server/apiserver.pp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,19 @@
' resources {',
' type = \'Class\' and',
' title = \'K8s::Server::Etcd\' and',
" parameters.cluster_name = '${etcd_cluster_name}' and",
" parameters.puppetdb_discovery_tag = '${puppetdb_discovery_tag}'",
($etcd_cluster_name ? {
undef => undef,
default => " parameters.cluster_name = '${etcd_cluster_name}' and",
}),
($puppetdb_discovery_tag ? {
undef => undef,
default => " parameters.puppetdb_discovery_tag = '${puppetdb_discovery_tag}' and",
}),
' }',
' }',
' order by certname',
'}',
].join(' ')
].delete_undef_values().join(' ')

$cluster_nodes = puppetdb_query($pql_query)
$_discovery = {
Expand Down
15 changes: 9 additions & 6 deletions manifests/server/etcd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@
}

if $ensure == 'present' and $manage_members {
$_cluster_name = pick($cluster_name, $k8s::etcd_cluster_name, 'default')
$_puppetdb_discovery_tag = pick($puppetdb_discovery_tag, $cluster_name, $k8s::puppetdb_discovery_tag, 'default')

# Needs the PuppetDB terminus installed
$pql_query = [
'resources[certname,parameters] {',
Expand All @@ -131,13 +128,19 @@
' resources {',
' type = \'Class\' and',
' title = \'K8s::Server::Etcd\' and',
" parameters.cluster_name = '${_cluster_name}' and",
" parameters.puppetdb_discovery_tag = '${_puppetdb_discovery_tag}' and",
($cluster_name ? {
undef => undef,
default => " parameters.cluster_name = '${cluster_name}' and",
}),
($puppetdb_discovery_tag ? {
undef => undef,
default => " parameters.puppetdb_discovery_tag = '${puppetdb_discovery_tag}' and",
}),
" certname != '${trusted[certname]}'",
' }',
' }',
' order by certname }',
].join(' ')
].delete_undef_values().join(' ')

$cluster_nodes = puppetdb_query($pql_query)
$_setup_splat = {
Expand Down

0 comments on commit 351a15f

Please sign in to comment.