Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/puppet/provider/foreman_config_entry/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def value

def value=(value)
return if resource[:dry]

value = value.unwrap if value.respond_to?(:unwrap)
run_foreman_config("-k '#{name}' -v '#{value}'", :combine => true, :failonfail => true)
@property_hash[:value] = value
end
Expand Down
2 changes: 1 addition & 1 deletion manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
String $version = $foreman::cli::params::version,
Boolean $manage_root_config = $foreman::cli::params::manage_root_config,
Optional[String] $username = $foreman::cli::params::username,
Optional[String] $password = $foreman::cli::params::password,
Optional[Variant[String, Sensitive[String]]] $password = $foreman::cli::params::password,
Boolean $use_sessions = $foreman::cli::params::use_sessions,
Boolean $refresh_cache = $foreman::cli::params::refresh_cache,
Integer[-1] $request_timeout = $foreman::cli::params::request_timeout,
Expand Down
2 changes: 1 addition & 1 deletion manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if $foreman::db_manage_rake {
$seed_env = {
'SEED_ADMIN_USER' => $foreman::initial_admin_username,
'SEED_ADMIN_PASSWORD' => $foreman::initial_admin_password,
'SEED_ADMIN_PASSWORD' => if $foreman::initial_admin_password =~ Sensitive {$foreman::initial_admin_password.unwrap} else {$foreman::initial_admin_password},
'SEED_ADMIN_FIRST_NAME' => $foreman::initial_admin_first_name,
'SEED_ADMIN_LAST_NAME' => $foreman::initial_admin_last_name,
'SEED_ADMIN_EMAIL' => $foreman::initial_admin_email,
Expand Down
10 changes: 5 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
Variant[Undef, Enum['UNSET'], Stdlib::Port] $db_port = 'UNSET',
Optional[String] $db_database = 'UNSET',
Optional[String] $db_username = $foreman::params::db_username,
Optional[String] $db_password = $foreman::params::db_password,
Optional[Variant[String, Sensitive[String]]] $db_password = $foreman::params::db_password,
Optional[String] $db_sslmode = 'UNSET',
Optional[String] $db_root_cert = undef,
Integer[0] $db_pool = $foreman::params::db_pool,
Expand All @@ -234,11 +234,11 @@
Stdlib::Absolutepath $client_ssl_key = $foreman::params::client_ssl_key,
Boolean $oauth_active = $foreman::params::oauth_active,
Boolean $oauth_map_users = $foreman::params::oauth_map_users,
String $oauth_consumer_key = $foreman::params::oauth_consumer_key,
String $oauth_consumer_secret = $foreman::params::oauth_consumer_secret,
Variant[String, Sensitive[String]] $oauth_consumer_key = $foreman::params::oauth_consumer_key,
Variant[String, Sensitive[String]] $oauth_consumer_secret = $foreman::params::oauth_consumer_secret,
String $oauth_effective_user = $foreman::params::oauth_effective_user,
String $initial_admin_username = $foreman::params::initial_admin_username,
String $initial_admin_password = $foreman::params::initial_admin_password,
Variant[String, Sensitive[String]] $initial_admin_password = $foreman::params::initial_admin_password,
Optional[String] $initial_admin_first_name = $foreman::params::initial_admin_first_name,
Optional[String] $initial_admin_last_name = $foreman::params::initial_admin_last_name,
Optional[String] $initial_admin_email = $foreman::params::initial_admin_email,
Expand All @@ -265,7 +265,7 @@
Optional[Stdlib::Fqdn] $email_smtp_domain = $foreman::params::email_smtp_domain,
Enum['none', 'plain', 'login', 'cram-md5'] $email_smtp_authentication = $foreman::params::email_smtp_authentication,
Optional[String] $email_smtp_user_name = $foreman::params::email_smtp_user_name,
Optional[String] $email_smtp_password = $foreman::params::email_smtp_password,
Optional[Variant[String, Sensitive[String]]] $email_smtp_password = $foreman::params::email_smtp_password,
Optional[String] $email_reply_address = $foreman::params::email_reply_address,
Optional[String] $email_subject_prefix = $foreman::params::email_subject_prefix,
String $telemetry_prefix = $foreman::params::telemetry_prefix,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
String[1] $config_file_owner = 'root',
String[1] $config_file_group = $foreman::group,
Stdlib::Filemode $config_file_mode = '0640',
Optional[String] $config = undef,
Optional[Variant[String, Sensitive[String]]] $config = undef,
) {
# Debian gem2deb converts underscores to hyphens
case $facts['os']['family'] {
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/supervisory_authority.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#
class foreman::plugin::supervisory_authority (
Stdlib::HTTPUrl $server_url,
String $secret_token,
Variant[String, Sensitive[String]] $secret_token,
Pattern[/^[a-zA-Z0-9 _-]+$/] $service_name,
Integer[0,5] $log_level = 1,
Integer[0] $pool_size = 1,
Expand Down
14 changes: 14 additions & 0 deletions spec/classes/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@
end
end

describe 'with all parameters and Sensitive for Secrets' do
let :params do
{
db_password: sensitive('secret'),
oauth_consumer_key: sensitive('random'),
oauth_consumer_secret: sensitive('random'),
initial_admin_password: sensitive('secret'),
email_smtp_password: sensitive('secret'),
}
end

it { is_expected.to compile.with_all_deps }
end

context 'with journald logging' do
let(:params) { super().merge(logging_type: 'journald') }
it { is_expected.to compile.with_all_deps }
Expand Down
30 changes: 22 additions & 8 deletions spec/classes/plugin/supervisory_authority_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
require 'spec_helper'

describe 'foreman::plugin::supervisory_authority' do
let(:params) do
{
'server_url' => 'https://example.com',
'secret_token' => 'secret_example',
'service_name' => 'foreman prod',
}
context 'with Standard-Parameters' do
let(:params) do
{
'server_url' => 'https://example.com',
'secret_token' => 'secret_example',
'service_name' => 'foreman prod',
}
end
include_examples 'basic foreman plugin tests', 'supervisory_authority'
it { is_expected.to contain_foreman__plugin('supervisory_authority').with_config(%r{^---\n:foreman_supervisory_authority:\n server_url: https://example\.com\n}) }
end

context 'with Sensitive secret_token' do
let(:params) do
{
'server_url' => 'https://example.com',
'secret_token' => sensitive('secret_example'),
'service_name' => 'foreman prod',
}
end
include_examples 'basic foreman plugin tests', 'supervisory_authority'
it { is_expected.to contain_foreman__plugin('supervisory_authority').with_config(%r{^---\n:foreman_supervisory_authority:\n server_url: https://example\.com\n}) }
end
include_examples 'basic foreman plugin tests', 'supervisory_authority'
it { is_expected.to contain_foreman__plugin('supervisory_authority').with_config(%r{^---\n:foreman_supervisory_authority:\n server_url: https://example\.com\n}) }
end
6 changes: 3 additions & 3 deletions templates/hammer_root.yml.epp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%- |
Optional[String] $username,
Optional[String] $password,
Optional[Variant[String, Sensitive[String]]] $password,
| -%>
:foreman:
# Credentials. You'll be asked for the interactively if you leave them blank here
:username: '<%= $username %>'
:password: '<%= $password %>'
:username:<%= if $username { " '${username}'" } %>
:password:<%= if $password { " '${password}'" } %>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow this doesn't work for me. In #1018 I'm adding a test, but doesn't unwrap the string. I also checked if it perhaps was the interpolation, but that also doesn't appear to be it.