Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try db_password to be Sensitive #1190

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
Optional[Stdlib::Port] $db_port = undef,
String[1] $db_database = 'foreman',
String[1] $db_username = 'foreman',
String[1] $db_password = $foreman::params::db_password,
Variant[String[1], Sensitive[String[1]]] $db_password = $foreman::params::db_password,
Optional[String[1]] $db_sslmode = undef,
Optional[String[1]] $db_root_cert = undef,
Optional[Integer[0]] $db_pool = undef,
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,17 @@

it { should contain_user('foreman').with('groups' => []) }
end

describe 'with sensitive passwords' do
let(:params) do
super().merge(db_password: sensitive('secret'))
end

it 'should configure the database' do

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on almalinux-8-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on almalinux-9-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on centos-8-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on centos-9-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on debian-11-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on debian-12-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on redhat-8-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on redhat-9-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on ubuntu-20.04-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

foreman on ubuntu-22.04-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on almalinux-8-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on ubuntu-22.04-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on centos-9-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on debian-11-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on ubuntu-20.04-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on redhat-9-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on redhat-8-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on debian-12-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on centos-8-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9

Check failure on line 493 in spec/classes/foreman_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

foreman on almalinux-9-x86_64 with sensitive passwords should configure the database Failure/Error: should contain_file('/etc/foreman/database.yml') .with_content(sensitive(/password: "secret"/)) expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to Sensitive(/password: "secret"/) but it is set to "---\n### File managed with puppet ###\n## Module: ''\n\n\n# Database is managed by foreman::database::postgresql\nproduction:\n adapter: postgresql\n database: foreman\n username: foreman\n password: {\"__ptype\" => \"Sensitive\", \"__pvalue\" => \"secret\"}\n pool: 9\n" Diff: @@ -1,12 +1,23 @@ -Sensitive [value redacted] +--- +### File managed with puppet ### +## Module: '' + + +# Database is managed by foreman::database::postgresql +production: + adapter: postgresql + database: foreman + username: foreman + password: {"__ptype" => "Sensitive", "__pvalue" => "secret"} + pool: 9
should contain_file('/etc/foreman/database.yml')
.with_content(sensitive(/password: "secret"/))
end
end
end
end
end
2 changes: 1 addition & 1 deletion templates/database.yml.epp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
username: <%= $username %>
<% } -%>
<% if $password { -%>
password: "<%= $password %>"
password: <%= stdlib::to_ruby($password) %>
Copy link
Member Author

Choose a reason for hiding this comment

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

If I drop this, I get:

expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to /password: "secret"/ but it is set to #<Sensitive [value redacted]>

so maybe with_content is a bad idea to begin with?

Copy link
Member Author

Choose a reason for hiding this comment

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

with_content(sensitive(…)) works for the plain case, but not once to_ruby is involved. yay

<% } -%>
pool: <%= $db_pool %>
Loading