-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
295 additions
and
27 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...uppet/provider/cpdb_create/cpdb_create.rb → lib/puppet/provider/cpdb_create/cpdb.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Puppet::Type.type(:cpdb_create).provide(:podman) do | ||
|
||
commands :podman => '/bin/podman' | ||
|
||
def create | ||
create_database | ||
write_done_file | ||
end | ||
|
||
def exists? | ||
File.exist?(done_file) | ||
end | ||
|
||
private | ||
|
||
def create_database | ||
podman( | ||
"run", | ||
"--network=host", | ||
"quay.io/ehelms/candlepin:4.3.12", | ||
"/usr/share/candlepin/cpdb", | ||
"--create", | ||
"--schema-only", | ||
"--dbhost=#{resource[:db_host]}", | ||
"--dbport=#{resource[:db_port]}", | ||
"--database=#{resource[:db_name]}#{resource[:ssl_options]}", | ||
"--user=#{resource[:db_user]}", | ||
"--password=#{resource[:db_password]}" | ||
) | ||
end | ||
|
||
def done_file | ||
"/var/lib/candlepin/.puppet-candlepin-cpdb-create-done" | ||
end | ||
|
||
def write_done_file | ||
File.open(done_file, 'w') do |file| | ||
file.write(Time.now) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Puppet::Type.type(:cpdb_update).provide(:podman) do | ||
|
||
commands :podman => 'podman' | ||
|
||
def create | ||
migrate_database | ||
update_version_file | ||
end | ||
|
||
def exists? | ||
return false if previous_candlepin_version.nil? | ||
return false if candlepin_rpm_version.nil? | ||
|
||
Gem::Version.new(previous_candlepin_version) == Gem::Version.new(candlepin_rpm_version) | ||
end | ||
|
||
private | ||
|
||
def migrate_database | ||
podman( | ||
"run", | ||
"--network=host", | ||
"quay.io/ehelms/candlepin:4.3.12", | ||
"/usr/share/candlepin/cpdb", | ||
"--update", | ||
"--dbhost=#{resource[:db_host]}", | ||
"--dbport=#{resource[:db_port]}", | ||
"--database=#{resource[:db_name]}#{resource[:ssl_options]}", | ||
"--user=#{resource[:db_user]}", | ||
"--password=#{resource[:db_password]}" | ||
) | ||
end | ||
|
||
def version_file | ||
"/var/lib/candlepin/.puppet-candlepin-rpm-version" | ||
end | ||
|
||
def update_version_file | ||
File.open(version_file, "w") do |file| | ||
file.write(candlepin_rpm_version) | ||
end | ||
end | ||
|
||
def candlepin_rpm_version | ||
podman( | ||
'run', | ||
"--network=host", | ||
"quay.io/ehelms/candlepin:4.3.12", | ||
'rpm', | ||
'-q', | ||
'candlepin', | ||
'--queryformat=%{version}' | ||
) | ||
end | ||
|
||
def previous_candlepin_version | ||
File.read(version_file) if File.exist?(version_file) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[Unit] | ||
Description=Candlepin | ||
After=local-fs.target | ||
|
||
[Container] | ||
Image=quay.io/ehelms/candlepin:4.3.12 | ||
PodmanArgs=--cgroups=enabled | ||
LogDriver=journald | ||
Network=host | ||
|
||
Volume=/etc/tomcat/logging.properties:/etc/tomcat/logging.properties | ||
Volume=/etc/tomcat/server.xml:/etc/tomcat/server.xml | ||
Volume=/etc/tomcat/login.config:/etc/tomcat/login.config | ||
Volume=/etc/tomcat/cert-roles.properties:/etc/tomcat/cert-roles.properties | ||
Volume=/etc/tomcat/cert-users.properties:/etc/tomcat/cert-users.properties | ||
Volume=/etc/tomcat/conf.d/jaas.conf:/etc/tomcat/conf.d/jaas.conf | ||
Volume=/etc/tomcat/tomcat.conf:/etc/tomcat/tomcat.conf | ||
Volume=/etc/candlepin:/etc/candlepin | ||
|
||
PublishPort=8443:8443 | ||
PublishPort=61613:61613 | ||
|
||
[Install] | ||
# Start by default on boot | ||
WantedBy=multi-user.target default.target |
Oops, something went wrong.