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

Respect all files extracted from tar_file #461

Draft
wants to merge 4 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
73 changes: 34 additions & 39 deletions manifests/ca.pp
Copy link
Member Author

Choose a reason for hiding this comment

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

Should the header be?

  Boolean $generate = $certs::generate and !$certs::tar_file,

Though I think it should be part of init.pp and reused in other places. Ideally we'd get rid of generate and regenerate altogether.

Original file line number Diff line number Diff line change
Expand Up @@ -21,60 +21,55 @@
String $ca_key_password = $certs::ca_key_password,
Stdlib::Absolutepath $ca_key_password_file = $certs::ca_key_password_file,
) {
$default_ca_path = "${certs::ssl_build_dir}/${default_ca_name}.crt"
$server_ca_path = "${certs::ssl_build_dir}/${server_ca_name}.crt"

file { $ca_key_password_file:
ensure => file,
content => $ca_key_password,
owner => 'root',
group => 'root',
mode => '0400',
show_diff => false,
} ~>
ca { $default_ca_name:
ensure => present,
common_name => $ca_common_name,
country => $country,
state => $state,
city => $city,
org => $org,
org_unit => $org_unit,
expiration => $ca_expiration,
generate => $generate,
password_file => $ca_key_password_file,
build_dir => $certs::ssl_build_dir,
}

if $generate {
if $certs::server_ca_cert {
file { $server_ca_path:
ensure => file,
source => $certs::server_ca_cert,
owner => 'root',
group => 'root',
mode => '0644',
}
} else {
file { $server_ca_path:
ensure => file,
source => "${certs::ssl_build_dir}/${default_ca_name}.crt",
owner => 'root',
group => 'root',
mode => '0644',
}
file { $ca_key_password_file:
ensure => file,
content => $ca_key_password,
owner => 'root',
group => 'root',
mode => '0400',
show_diff => false,
} ~>
ca { $default_ca_name:
ensure => present,
common_name => $ca_common_name,
country => $country,
state => $state,
city => $city,
org => $org,
org_unit => $org_unit,
expiration => $ca_expiration,
generate => $generate,
password_file => $ca_key_password_file,
build_dir => $certs::ssl_build_dir,
}

file { $server_ca_path:
ensure => file,
source => pick($certs::server_ca_cert, $default_ca_path),
owner => 'root',
group => 'root',
mode => '0644',
}

file { "${certs::ssl_build_dir}/KATELLO-TRUSTED-SSL-CERT":
ensure => link,
target => $server_ca_path,
require => File[$server_ca_path],
}

$default_ca = Ca[$default_ca_name]
} else {
$default_ca = undef
}

if $deploy {
file { $certs::katello_default_ca_cert:
ensure => file,
source => "${certs::ssl_build_dir}/${default_ca_name}.crt",
source => $default_ca_path,
owner => 'root',
group => 'root',
mode => '0644',
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@
Class['certs::config'] ->
Class['certs::ca']

$default_ca = Ca[$default_ca_name]
$default_ca = $certs::ca::default_ca
}
12 changes: 0 additions & 12 deletions spec/acceptance/apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@

context 'with server cert' do
before(:context) do
['crt', 'key'].each do |ext|
source_path = "fixtures/example.partial.solutions.#{ext}"
dest_path = "/server.#{ext}"
scp_to(hosts, source_path, dest_path)
end

# Force regen
on hosts, "if [ -e /root/ssl-build/#{fact('fqdn')} ] ; then touch /root/ssl-build/#{fact('fqdn')}/#{fact('fqdn')}-apache.update ; fi"
end
Expand Down Expand Up @@ -134,12 +128,6 @@ class { 'certs::apache':

context 'with custom certificates fresh' do
before(:context) do
['crt', 'key'].each do |ext|
source_path = "fixtures/example.partial.solutions.#{ext}"
dest_path = "/server.#{ext}"
scp_to(hosts, source_path, dest_path)
end

on hosts, 'rm -rf /root/ssl-build'
end

Expand Down
14 changes: 0 additions & 14 deletions spec/acceptance/certs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ class { 'certs':
end

context 'with server CA cert' do
before(:context) do
source_path = "fixtures/example.partial.solutions-chain.pem"
dest_path = "/server-ca.crt"
scp_to(hosts, source_path, dest_path)
end

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
Expand All @@ -153,14 +147,6 @@ class { 'certs':
end

context 'with tar file' do
before(:context) do
['crt', 'key'].each do |ext|
source_path = "fixtures/example.partial.solutions.#{ext}"
dest_path = "/server.#{ext}"
scp_to(hosts, source_path, dest_path)
end
end

context 'with default ca' do
before(:context) do
manifest = <<~PUPPET
Expand Down
6 changes: 0 additions & 6 deletions spec/acceptance/foreman_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@

context 'with custom certificates fresh' do
before(:context) do
['crt', 'key'].each do |ext|
source_path = "fixtures/example.partial.solutions.#{ext}"
dest_path = "/server.#{ext}"
scp_to(hosts, source_path, dest_path)
end

on hosts, 'rm -rf /root/ssl-build'
end

Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# refresh check if cache needs refresh on next yum command
on host, 'yum clean expire-cache'
end

scp_to(host, 'fixtures/example.partial.solutions.crt', '/server.crt')
scp_to(host, 'fixtures/example.partial.solutions.key', '/server.key')
scp_to(host, 'fixtures/example.partial.solutions-chain.pem', '/server-ca.crt')
end

Dir["./spec/support/acceptance/**/*.rb"].sort.each { |f| require f }
Empty file.
Loading