-
Notifications
You must be signed in to change notification settings - Fork 135
Fixes #29803 - Move --certs* to hooks/ #514
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Add options around regenerating certificates | ||
| if module_present?('certs') | ||
| app_option( | ||
| '--certs-update-server', | ||
| :flag, | ||
| "This option will enforce an update of the HTTPS certificates", | ||
| :default => false | ||
| ) | ||
| app_option( | ||
| '--certs-update-server-ca', | ||
| :flag, | ||
| "This option will enforce an update of the CA used for HTTPS certificates.", | ||
| :default => false | ||
| ) | ||
| app_option( | ||
| '--certs-update-all', | ||
| :flag, | ||
| "This option will enforce an update of all the certificates for given host", | ||
| :default => false | ||
| ) | ||
| app_option( | ||
| '--certs-reset', | ||
| :flag, | ||
| "This option will reset any custom certificates and use the self-signed CA " \ | ||
| "instead. Note that any clients will need to be updated with the latest " \ | ||
| "katello-ca-consumer RPM, and any external proxies will need to have the " \ | ||
| "certs updated by generating a new certs tarball.", | ||
| :default => false | ||
| ) | ||
| app_option( | ||
| '--certs-skip-check', | ||
| :flag, | ||
| "This option will cause skipping the certificates sanity check. Use with caution", | ||
| :default => false | ||
| ) | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| require 'fileutils' | ||
| require 'English' | ||
|
|
||
| if module_enabled?('certs') | ||
| SSL_BUILD_DIR = param('certs', 'ssl_build_dir').value | ||
|
|
||
| def mark_for_update(cert_name, hostname = nil) | ||
| path = File.join(*[SSL_BUILD_DIR, hostname, cert_name].compact) | ||
| if app_value(:noop) | ||
| puts "Marking certificate #{path} for update (noop)" | ||
| else | ||
| puts "Marking certificate #{path} for update" | ||
| FileUtils.touch("#{path}.update") | ||
| end | ||
| end | ||
|
|
||
| if param('foreman_proxy_certs', 'foreman_proxy_fqdn') | ||
| hostname = param('foreman_proxy_certs', 'foreman_proxy_fqdn').value | ||
| else | ||
| hostname = param('certs', 'node_fqdn').value | ||
| end | ||
|
|
||
| if app_value(:certs_update_server) | ||
| mark_for_update("#{hostname}-apache", hostname) | ||
| mark_for_update("#{hostname}-foreman-proxy", hostname) | ||
| end | ||
|
|
||
| if app_value(:certs_update_all) || app_value(:certs_update_default_ca) || app_value(:certs_reset) | ||
| all_cert_names = Dir.glob(File.join(SSL_BUILD_DIR, hostname, '*.noarch.rpm')).map do |rpm| | ||
| File.basename(rpm).sub(/-1\.0-\d+\.noarch\.rpm/, '') | ||
| end.uniq | ||
|
|
||
| all_cert_names.each do |cert_name| | ||
| mark_for_update(cert_name, hostname) | ||
| end | ||
| end | ||
|
|
||
| if app_value(:certs_update_server_ca) || app_value(:certs_reset) | ||
| mark_for_update('katello-server-ca') | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| if module_enabled?('certs') | ||
| if app_value(:certs_update_server_ca) && !module_enabled?('katello') | ||
| fail_and_exit("--certs-update-server-ca needs to be used with katello", 101) | ||
| end | ||
|
|
||
| if app_value(:certs_reset) | ||
| param('certs', 'server_cert').unset_value | ||
| param('certs', 'server_key').unset_value | ||
| param('certs', 'server_ca_cert').unset_value | ||
| end | ||
|
|
||
| ca_file = param('certs', 'server_ca_cert').value | ||
| cert_file = param('certs', 'server_cert').value | ||
| key_file = param('certs', 'server_key').value | ||
|
|
||
| if !app_value(:certs_skip_check) && !cert_file.to_s.empty? && | ||
| (app_value(:certs_update_server_ca) || app_value(:certs_update_server)) | ||
| execute_command(%(katello-certs-check -c "#{cert_file}" -k "#{key_file}" -b "#{ca_file}")) | ||
| end | ||
| end | ||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../../katello/hooks/boot/20-certs_update.rb | ||
| ../../../hooks/boot/20-certs_update.rb | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always forget these and what they're exactly supposed to do. It would be great to have some integration tests to make sure the functionality actually does what it's supposed to.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm working on theforeman/forklift#1208 as a first step towards integration testing of installer PRs. Could we go ahead and merge this, and add tests in a future PR?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, tests can come after. Please file a Redmine issue to not lose track of the need.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree they can come later, but I'm wonder how much we actually verified this continues to work. With the rest of the code I'm decently familiar with how it should work but I'm not that familiar with |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../../katello/hooks/pre/20-certs_update.rb | ||
| ../../../hooks/pre/20-certs_update.rb |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../hooks/pre_commit/20-certs_update.rb |
Uh oh!
There was an error while loading. Please reload this page.