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

Accept Sensitive for Secrets #436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cocker-cc
Copy link

No description provided.

@cocker-cc
Copy link
Author

Related: theforeman/puppet-candlepin#210

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I wonder if this would need to require a sufficiently recent version of the candlepin module in metadata.json. It certainly depends on it so I won't merge this until the other PR has been.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Could you also add a unit test to ensure it works end to end?

I'm currently looking into a failure to parse Variant[ which I don't understand (https://community.theforeman.org/t/foreman-installer-develop-package-release-1015-failed/26627) so I'm first going to investigate that. It could be unrelated but then you at least know where I'm at.

@ekohl
Copy link
Member

ekohl commented Dec 24, 2021

The good news is that that failure is unrelated but the bad news is that it looks like something else broke our CI.

@cocker-cc
Copy link
Author

The good news is that that failure is unrelated but the bad news is that it looks like something else broke our CI.

     #   wrong number of arguments (given 5, expected 1)
     #   ./vendor/bundle/ruby/2.7.0/gems/psych-4.0.3/lib/psych.rb:323:in `safe_load'

Try pinning psych to Version 3.

@ekohl
Copy link
Member

ekohl commented Jan 3, 2022

I'd like to see where puppetlabs/puppet#8849 goes first.

@@ -50,7 +50,7 @@
Optional[Stdlib::Port] $candlepin_db_port = undef,
String $candlepin_db_name = 'candlepin',
String $candlepin_db_user = 'candlepin',
Optional[String] $candlepin_db_password = undef,
Optional[Variant[Sensitive[String], String]] $candlepin_db_password = undef,
Copy link
Member

Choose a reason for hiding this comment

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

I found with puppet-foreman testing that this wouldn't work well with our installer. It writes out all the answers so you end up with Sensitive[Undef], which isn't accepted here.

So what you end with in the installer answers file is:

katello:
  candlepin_db_password:

I think this translates to Hiera as:

katello::candlepin_db_password:

So that ends up sending undef via Hiera. If you add a conversion to sensitive in Hiera using lookup_options, this ends up as Sensitive[Undef].

Suggested change
Optional[Variant[Sensitive[String], String]] $candlepin_db_password = undef,
Variant[Sensitive[Optional[String]], Optional[String]] $db_password = undef,

This would then also need to be reflected in all other types.

I merged theforeman/kafo#345, will release it shortly. I'm also considering a solution where we add the lookup option and use this option:

Suggested change
Optional[Variant[Sensitive[String], String]] $candlepin_db_password = undef,
Sensitive[Optional[String]] $candlepin_db_password = sensitive(undef),

That would be a lot more straight forward. It may be breaking to users who pass in arguments directly from Puppet, but we can look at that.

Copy link
Author

@cocker-cc cocker-cc Feb 9, 2022

Choose a reason for hiding this comment

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

I have no Knowledge, how the Installer-Answer-File works, but Hiera does not translate

katello:
  candlepin_db_password:

to katello::candlepin_db_password. Instead what Hiera does here, is: Lookup a Hash named katello, find the Hash named katello, which turns out to have a Key named candlepin_db_password.

Isn't it possible to state an empty String "" instead of "nothing"

katello:
  candlepin_db_password: ""

in the Installer-Answer-File?

Copy link
Member

Choose a reason for hiding this comment

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

Not really. What the installer does is that it extracts the default value from Puppet and stores that. Thinking more about it, other code would probably also fail, like if $candlepin_db_password {} is "false" with undef but perhaps Sensitive[Undef] may not.

I wonder if this is a more fundamental problem in Puppet and the lookup option may provide to only convert it if it isn't undef. Perhaps we need a conversion function that essentially is to_optional_sensitive(Optional[Any]) -> Optional[Sensitive[Any]]) (compared to sensitive(Any) -> Sensitive[Any]). Does that make sense?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this totally makes Sense.
I created an Issue in the Hiera-Board: https://tickets.puppetlabs.com/browse/HI-628

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! In theforeman/puppet-foreman#1018 we had a less structured discussion but I think I now understand the problem properly and I'm an issue there is helpful moving it forward. Thanks for distilling it down to the minimal problem statement.

@cocker-cc cocker-cc force-pushed the Accept_Sensitive_for_Secrets branch from ec7aca5 to a532555 Compare June 13, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants