Skip to content

Commit

Permalink
Merge pull request #41 from bastelfreak/puppetdb
Browse files Browse the repository at this point in the history
bolt project: Make PuppetDB URIs configureable
  • Loading branch information
bastelfreak authored Nov 14, 2024
2 parents b3f4d05 + f66aff7 commit 85f0cbd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

##### <a name="-bolt--project--basepath"></a>`basepath`

Expand Down Expand Up @@ -215,3 +216,11 @@ the bolt tmpdir for all local transports

Default value: `undef`

##### <a name="-bolt--project--puppetdb_urls"></a>`puppetdb_urls`

Data type: `Array[Stdlib::HTTPUrl]`

URIs for PuppetDB, usually the localhost http listener

Default value: `['http://127.0.0.1:8080']`

4 changes: 3 additions & 1 deletion manifests/project.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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': }
Expand All @@ -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')
Expand Down Expand Up @@ -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":
Expand Down
10 changes: 9 additions & 1 deletion spec/defines/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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 }
Expand Down

0 comments on commit 85f0cbd

Please sign in to comment.