From ec1ab3142711d3b05626cd5bb21547790e61fef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Fr=C3=B6hner?= Date: Mon, 26 Feb 2024 09:53:17 +0100 Subject: [PATCH] Add initial_admin_password parameter See also: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/debian/#step-1-download-and-install-opensearch --- manifests/init.pp | 3 +++ manifests/install/package.pp | 5 +++++ spec/acceptance/default_spec.rb | 13 +++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index a173514..7174fcb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,6 +20,8 @@ # Whether to enable the `apt::pin` or `yum::versionlock` for the package. # @param apt_pin_priority # The priority for apt::pin of the opensearch package. +# @param initial_admin_password +# Password for intial installation of the package. # # @param manage_config # Whether to manage the configuration. @@ -116,6 +118,7 @@ Enum['x64', 'arm64'] $package_architecture, Enum['dpkg', 'rpm'] $package_provider, Hash $default_settings, + String[1] $initial_admin_password, ## ## version diff --git a/manifests/install/package.pp b/manifests/install/package.pp index e63c468..6f8c348 100644 --- a/manifests/install/package.pp +++ b/manifests/install/package.pp @@ -61,9 +61,14 @@ } } + exec { 'set_initial_password_environment': + command => "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=${opensearch::initial_admin_password}" + } + package { 'opensearch': ensure => $ensure, provider => $provider, source => $source, + require => Exec['set_initial_password_environment'], } } diff --git a/spec/acceptance/default_spec.rb b/spec/acceptance/default_spec.rb index 54cc8b0..1ca846e 100644 --- a/spec/acceptance/default_spec.rb +++ b/spec/acceptance/default_spec.rb @@ -6,7 +6,11 @@ context 'default parameter' do it_behaves_like 'an idempotent resource' do let(:manifest) do - 'include opensearch' + <<~PP + class { 'opensearch': + initial_admin_password => 'some_random_password', + } + PP end end @@ -49,9 +53,10 @@ let(:manifest) do <<~PP class { 'opensearch': - version => '2.9.0', - package_source => 'archive', - settings => { + version => '2.9.0', + package_source => 'archive', + initial_admin_password => 'some_random_password', + settings => { # When installing from an archive, the demo certificates are not # installed by default. 'plugins.security.disabled' => true,