From f66aff79dc6f62be9c3dae7d6aa7061499923d45 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 14 Nov 2024 13:38:00 +0100 Subject: [PATCH] bolt project: Make PuppetDB URIs configureable --- REFERENCE.md | 9 +++++++++ manifests/project.pp | 4 +++- spec/defines/project_spec.rb | 10 +++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index d87202c..8eaddc8 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -150,6 +150,7 @@ The following parameters are available in the `bolt::project` defined type: * [`environment`](#-bolt--project--environment) * [`modulepaths`](#-bolt--project--modulepaths) * [`local_transport_tmpdir`](#-bolt--project--local_transport_tmpdir) +* [`puppetdb_urls`](#-bolt--project--puppetdb_urls) ##### `basepath` @@ -215,3 +216,11 @@ the bolt tmpdir for all local transports Default value: `undef` +##### `puppetdb_urls` + +Data type: `Array[Stdlib::HTTPUrl]` + +URIs for PuppetDB, usually the localhost http listener + +Default value: `['http://127.0.0.1:8080']` + diff --git a/manifests/project.pp b/manifests/project.pp index 0bb3657..93269a7 100644 --- a/manifests/project.pp +++ b/manifests/project.pp @@ -9,6 +9,7 @@ # @param environment the desired code environment we will use # @param modulepaths an array of directories where code lives # @param local_transport_tmpdir the bolt tmpdir for all local transports +# @param puppetdb_urls URIs for PuppetDB, usually the localhost http listener # # @example create one project and provide plan parameters # bolt::project { 'peadmmig': } @@ -29,6 +30,7 @@ String[1] $environment = 'peadm', Array[Stdlib::Absolutepath] $modulepaths = ["/etc/puppetlabs/code/environments/${environment}/modules", "/etc/puppetlabs/code/environments/${environment}/site", '/opt/puppetlabs/puppet/modules'], Optional[Stdlib::Absolutepath] $local_transport_tmpdir = undef, + Array[Stdlib::HTTPUrl] $puppetdb_urls = ['http://127.0.0.1:8080'], ) { unless $facts['pe_status_check_role'] { fail('pe_status_check_role fact is missing from module puppetlabs/pe_status_check') @@ -70,7 +72,7 @@ 'name' => $project, 'modulepath' => $modulepaths, 'stream' => true, - 'puppetdb' => { 'server_urls' => ['http://127.0.0.1:8080'] }, + 'puppetdb' => { 'server_urls' => $puppetdb_urls }, }.stdlib::to_yaml({ 'indentation' => 2 }) file { "${project_path}/bolt-project.yaml": diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index fe83994..b96ae71 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -23,7 +23,7 @@ context 'with defaults' do it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('bolt') } - it { is_expected.to contain_file('/opt/peadm/bolt-project.yaml').with_ensure('file') } + it { is_expected.to contain_file('/opt/peadm/bolt-project.yaml').with_ensure('file').with_content(%r{http://127.0.0.1:8080}) } it { is_expected.to contain_file('/opt/peadm/inventory.yaml').with_ensure('file').without_content(%r{tmpdir}) } it { is_expected.to contain_file('/opt/peadm').with_ensure('directory') } it { is_expected.to contain_user(title) } @@ -42,6 +42,14 @@ end end + context 'with https PuppetDB URL' do + let :params do + { puppetdb_urls: ['https://[::1]:8081'] } + end + + it { is_expected.to contain_file('/opt/peadm/bolt-project.yaml').with_ensure('file').with_content(%r{https://\[::1\]:8081}) } + end + context 'with manage_user=false on PE' do let :params do { manage_user: false }