-
Notifications
You must be signed in to change notification settings - Fork 29
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
PoC to deploy with quadlets #255
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
#TODO: Add Artemis listening test https://projects.theforeman.org/issues/29561 | ||
|
||
describe 'candlepin works as a container' do | ||
before(:all) do | ||
cleanup_installation | ||
end | ||
|
||
it_behaves_like 'an idempotent resource' do | ||
let(:manifest) do | ||
basic_manifest(true) | ||
end | ||
end | ||
|
||
describe port(8443) do | ||
it { is_expected.to be_listening } | ||
end | ||
|
||
describe package('candlepin') do | ||
it { is_expected.not_to be_installed } | ||
end | ||
|
||
describe file("/etc/containers/systemd/tomcat.container") do | ||
it { should be_file } | ||
it { should be_mode 440 } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
end | ||
|
||
describe command('curl -k -s -o /dev/null -w \'%{http_code}\' https://localhost:8443/candlepin/status') do | ||
its(:stdout) { should eq "200" } | ||
end | ||
|
||
describe command('nmap --script +ssl-enum-ciphers localhost -p 8443') do | ||
# We don't enable TLSv1.3 by default yet. TLSv1.3 support was added in tomcat 7.0.92 | ||
# But tomcat 7.0.76 is the latest version available on EL7 | ||
its(:stdout) { should_not match(/TLSv1\.3/) } | ||
|
||
# Test that TLSv1.2 is enabled | ||
its(:stdout) { should match(/TLSv1\.2/) } | ||
|
||
# Test that older TLS versions are disabled | ||
its(:stdout) { should_not match(/TLSv1\.1/) } | ||
its(:stdout) { should_not match(/TLSv1\.0/) } | ||
|
||
# Test that the least cipher strength is "strong" or "A" | ||
its(:stdout) { should match(/least strength: (A|strong)/) } | ||
end | ||
|
||
describe file("/etc/tomcat/cert-users.properties") do | ||
it { should be_file } | ||
it { should be_mode 640 } | ||
it { should be_owned_by 'tomcat' } | ||
it { should be_grouped_into 'tomcat' } | ||
its(:content) { should eq("katelloUser=CN=ActiveMQ Artemis Deferred, OU=Artemis, O=ActiveMQ, L=AMQ, ST=AMQ, C=AMQ\n") } | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
def basic_manifest(container = true) | ||
return <<-MANIFEST | ||
$keydir = '/etc/candlepin/certs' | ||
$keystore = "${keydir}/keystore" | ||
$keystore_password = 'secret' | ||
$truststore = "${keydir}/truststore" | ||
$truststore_password = 'secret' | ||
$ca_key = "${keydir}/candlepin-ca.key" | ||
$ca_cert = "${keydir}/candlepin-ca.crt" | ||
|
||
exec { "/bin/mkdir -p ${keydir}": | ||
creates => $keydir, | ||
} -> | ||
exec { 'Create CA key': | ||
command => "/usr/bin/openssl genrsa -out '${ca_key}' 2048", | ||
creates => $ca_key, | ||
notify => Service['tomcat'], | ||
} -> | ||
exec { 'Create CA certficate': | ||
command => "/usr/bin/openssl req -new -x509 -key '${ca_key}' -out '${ca_cert}' -nodes -x509 -subj '/C=US/ST=North Carolina/L=Raleigh/O=CustomKatelloCA/CN=${facts['networking']['fqdn']}'", | ||
creates => $ca_cert, | ||
notify => Service['tomcat'], | ||
} -> | ||
exec { 'Create keystore': | ||
command => "/usr/bin/openssl pkcs12 -export -in '${ca_cert}' -inkey '${ca_key}' -out '${keystore}' -name tomcat -CAfile '${ca_cert}' -caname root -password 'pass:${keystore_password}'", | ||
creates => $keystore, | ||
notify => Service['tomcat'], | ||
} -> | ||
package { ['java']: } -> | ||
exec { 'Create truststore': | ||
command => "/usr/bin/keytool -import -v -keystore ${truststore} -alias candlepin-ca -file ${ca_cert} -noprompt -storepass ${truststore_password} -storetype pkcs12", | ||
creates => $truststore, | ||
} -> | ||
file { $ca_key: | ||
mode => '0440', | ||
group => 'tomcat', | ||
} -> | ||
file { $ca_cert: | ||
mode => '0440', | ||
group => 'tomcat', | ||
} -> | ||
file { $keystore: | ||
mode => '0440', | ||
group => 'tomcat', | ||
} -> | ||
file { $truststore: | ||
mode => '0440', | ||
group => 'tomcat', | ||
} -> | ||
class { 'candlepin': | ||
ca_key => $ca_key, | ||
ca_cert => $ca_cert, | ||
keystore_file => $keystore, | ||
keystore_password => $keystore_password, | ||
truststore_file => $truststore, | ||
truststore_password => $truststore_password, | ||
java_package => 'java-17-openjdk', | ||
java_home => '/usr/lib/jvm/jre-17', | ||
artemis_client_dn => Deferred('pick', ['', 'CN=ActiveMQ Artemis Deferred, OU=Artemis, O=ActiveMQ, L=AMQ, ST=AMQ, C=AMQ']), | ||
use_container => #{container}, | ||
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 not that happy with the duplication and essentially templating. For the container use case I assume the 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. What duplication? |
||
} | ||
MANIFEST | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def cleanup_installation | ||
on default, 'dnf -y remove candlepin candlepin-selinux pki-*' | ||
on default, 'rm -rf /etc/tomcat /etc/candlepin' | ||
on default, 'rm -rf /etc/containers/systemd/tomcat.container' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<%- | | ||
String[1] $image, | ||
| -%> | ||
### File managed with puppet ### | ||
## Module: '<%= $module_name %>' | ||
[Unit] | ||
Description=Candlepin | ||
After=local-fs.target | ||
|
||
[Install] | ||
WantedBy=multi-user.target default.target | ||
|
||
[Container] | ||
Image=<%= $image %> | ||
PodmanArgs=--cgroups=enabled | ||
LogDriver=journald | ||
Network=host | ||
|
||
Volume=/etc/tomcat/server.xml:/etc/tomcat/server.xml:Z | ||
Volume=/etc/tomcat/login.config:/etc/tomcat/login.config:Z | ||
Volume=/etc/tomcat/cert-roles.properties:/etc/tomcat/cert-roles.properties:Z | ||
Volume=/etc/tomcat/cert-users.properties:/etc/tomcat/cert-users.properties:Z | ||
Volume=/etc/tomcat/conf.d/jaas.conf:/etc/tomcat/conf.d/jaas.conf:Z | ||
Volume=/etc/tomcat/tomcat.conf:/etc/tomcat/tomcat.conf:Z | ||
Volume=/etc/candlepin:/etc/candlepin:Z | ||
Volume=/var/log/candlepin:/var/log/candlepin:Z | ||
Volume=/var/log/tomcat:/var/log/tomcat:Z | ||
Comment on lines
+19
to
+27
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. In my testing of a completely unrelated application I didn't need 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 think it depends on the application, the path, if it's read-only or read-write needed and SELinux policy as I understand it. These two have some useful info:
Comment on lines
+26
to
+27
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. Can we configure candlepin (and Tomcat) to log everything to the journal and avoid these log directories? 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. Fair question - generally I think yes. There are some things already logged to the journal but not everything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also be tempted to try southalc/podman#83. Comparing the two, your code doesn't take care of the
daemon-reload
that's needed when it changes. If we end up doing more with quadlets then it'll reduce the duplication.