Skip to content

Commit

Permalink
First pass at updates to parameterize and make use of newer puppet
Browse files Browse the repository at this point in the history
modules for configuring and setting up the Katello engine.
  • Loading branch information
ehelms committed Jan 6, 2014
1 parent e688c3e commit ae7d4aa
Show file tree
Hide file tree
Showing 17 changed files with 1,383 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.vagrant
*.swp
*.swo

.bundle
vendor/

pkg/

Gemfile.lock

.rbenv*
.rvmrc*
.ruby-version

spec/fixtures/
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: ruby
rvm:
- 1.9.3
script:
- rake lint
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

if ENV.key?('PUPPET_VERSION')
puppetversion = "~> #{ENV['PUPPET_VERSION']}"
else
puppetversion = ['>= 2.6']
end

gem 'puppet', puppetversion
gem 'puppet-lint', '>=0.3.2'
621 changes: 621 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'puppet-lint/tasks/puppet-lint'

PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}'
PuppetLint.configuration.send("disable_class_inherits_from_params_class")
PuppetLint.configuration.send("disable_80chars")

task :default => [:lint]
128 changes: 128 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
class katello::config {
include katello::config::files

# user { $katello::user:
# ensure => 'present',
# shell => '/sbin/nologin',
# comment => 'Katello',
# gid => $katello::group,
# require => Class['katello::install'],
# }

# exec { 'ktmigrate':
# command => "${foreman::app_root}/extras/dbmigrate",
# user => $foreman::user,
# environment => "HOME=${foreman::app_root}",
# logoutput => 'on_failure',
# } ->
#File["/etc/sysconfig/katello"] ~> Exec["reload-apache"]
#File["/etc/httpd/conf.d/katello.d"] ~>
#File["/etc/httpd/conf.d/katello.d/katello.conf"] ~> Exec["reload-apache"]
#File["/etc/httpd/conf.d/katello.conf"] ~> Exec["reload-apache"]


# exec {"httpd-restart":
# command => "/bin/sleep 5; /sbin/service httpd restart; /bin/sleep 10",
# onlyif => "/usr/sbin/apachectl -t",
# before => Exec["katello_seed_db"],
# require => $katello::params::deployment ? {
# 'katello' => [ File["${katello::params::config_dir}/katello.yml"], Class["candlepin::service"], Class["pulp::service"] ],
# 'headpin' => [ File["${katello::params::config_dir}/katello.yml"], Class["candlepin::service"], Class["thumbslug::service"] ],
# default => [],
# },
# refreshonly => true,
# }
#
# exec {"katello_db_printenv":
# cwd => $katello::params::katello_dir,
# user => $katello::params::user,
# environment => "RAILS_ENV=${katello::params::environment}",
# command => "/usr/bin/env > ${katello::params::db_env_log}",
# creates => "${katello::params::db_env_log}",
# before => Class["katello::service"],
# require => $katello::params::deployment ? {
# 'katello' => [
# Class["candlepin::service"],
# Class["pulp::service"],
# Class["foreman"],
# File["${katello::params::log_base}"],
# File["${katello::params::log_base}/production.log"],
# File["${katello::params::log_base}/production_sql.log"],
# File["${katello::params::config_dir}/katello.yml"]
# ],
# 'headpin' => [
# Class["candlepin::service"],
# Class["thumbslug::service"],
# Class["foreman"],
# File["${katello::params::log_base}"],
# File["${katello::params::config_dir}/katello.yml"]
# ],
# default => [],
# },
# }
#
# if $katello::params::reset_data == 'YES' {
# exec {"reset_katello_db":
# command => "rm -f /var/lib/katello/db_seed_done; rm -f /var/lib/katello/db_migrate_done; service katello stop; service katello-jobs stop; test 1 -eq 1",
# path => "/sbin:/bin:/usr/bin",
# before => Exec["katello_migrate_db"],
# notify => Postgresql::Dropdb["$katello::params::db_name"],
# }
# postgresql::dropdb {$katello::params::db_name:
# logfile => "${katello::params::configure_log_base}/drop-postgresql-katello-database.log",
# require => [ Postgresql::Createuser[$katello::params::db_user], File["${katello::params::configure_log_base}"] ],
# before => Exec["katello_migrate_db"],
# refreshonly => true,
# notify => [
# Postgresql::Createdb[$katello::params::db_name],
# Exec["katello_db_printenv"],
# Exec["katello_migrate_db"],
# Exec["katello_seed_db"],
# ],
# }
# }
#
# exec {"katello_migrate_db":
# cwd => $katello::params::katello_dir,
# user => "root",
# environment => ["RAILS_ENV=${katello::params::environment}", "BUNDLER_EXT_NOSTRICT=1"],
# command => "/usr/bin/${katello::params::scl_prefix}rake db:migrate --trace --verbose > ${katello::params::migrate_log} 2>&1 && touch /var/lib/katello/db_migrate_done",
# creates => "/var/lib/katello/db_migrate_done",
# before => Class["katello::service"],
# require => [ Exec["katello_db_printenv"] ],
# }
#
# exec {"katello_seed_db":
# cwd => $katello::params::katello_dir,
# user => "root",
# environment => ["RAILS_ENV=${katello::params::environment}", "KATELLO_LOGGING=debug", "BUNDLER_EXT_NOSTRICT=1"],
# command => "/usr/bin/${katello::params::scl_prefix}rake seed_with_logging --trace --verbose > ${katello::params::seed_log} 2>&1 && touch /var/lib/katello/db_seed_done",
# creates => "/var/lib/katello/db_seed_done",
# before => Class["katello::service"],
# require => $katello::params::deployment ? {
# 'katello' => [ Exec["katello_migrate_db"], Class["candlepin::service"], Class["pulp::service"], File["${katello::params::log_base}"] ],
# 'headpin' => [ Exec["katello_migrate_db"], Class["candlepin::service"], Class["thumbslug::service"], File["${katello::params::log_base}"] ],
# default => [],
# },
# }
#
# # during first installation we mark all 'once' upgrade scripts as executed
# exec {"update_upgrade_history":
# cwd => "${katello::params::katello_upgrade_scripts_dir}",
# command => "grep -E '#.*run:.*once' * | awk -F: '{print \$1}' > ${katello::params::katello_upgrade_history_file}",
# creates => "${katello::params::katello_upgrade_history_file}",
# path => "/bin",
# before => Class["katello::service"],
# }
#
# # Headpin does not care about pulp
# #case $katello::params::deployment {
# # 'katello': {
# # Class["candlepin::config"] -> File["/etc/pulp/server.conf"]
# # Class["candlepin::config"] -> File["/etc/pulp/repo_auth.conf"]
# # Class["candlepin::config"] -> File["/etc/pki/pulp/content/pulp-global-repo.ca"]
# # }
# # default : {}
# #}

}
80 changes: 80 additions & 0 deletions manifests/config/files.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
class katello::config::files {

include katello::params

# this should be required by all classes that need to log there (one of these)
file {
"${katello::params::log_base}":
owner => $katello::params::user,
group => $katello::params::group,
mode => 750;
# this is a symlink when called via katello-configure
"${katello::params::configure_log_base}":
owner => $katello::params::user,
group => $katello::params::group,
mode => 750;
}

file { '/usr/share/foreman/bundler.d/katello.rb':
ensure => file,
owner => $katello::params::user,
group => $katello::user_groups,
mode => "0644",
}

# create Rails logs in advance to get correct owners and permissions
file {[
"${katello::params::log_base}/production.log",
"${katello::params::log_base}/production_sql.log",
"${katello::params::log_base}/production_delayed_jobs.log",
"${katello::params::log_base}/production_delayed_jobs_sql.log",
"${katello::params::log_base}/production_orch.log",
"${katello::params::log_base}/production_delayed_jobs_orch.log"]:
owner => $katello::params::user,
group => $katello::params::group,
content => "",
replace => false,
mode => 640,
}

file {
"${katello::params::config_dir}/katello.yml":
ensure => file,
content => template("katello/${katello::params::config_dir}/katello.yml.erb"),
owner => $katello::params::user,
group => $katello::user_groups,
mode => "0644",
before => [Class['foreman::database'], Exec['foreman-rake-db:migrate']];

"/etc/sysconfig/katello":
content => template("katello/etc/sysconfig/katello.erb"),
owner => "root",
group => "root",
mode => "644";

"/etc/katello/client.conf":
content => template("katello/etc/katello/client.conf.erb"),
owner => "root",
group => "root",
mode => "644";

# "/etc/httpd/conf.d/katello.conf":
# content => template("katello/etc/httpd/conf.d/katello.conf.erb"),
# owner => "root",
# group => "root",
# mode => "0644";
#
# "/etc/httpd/conf.d/katello.d":
# ensure => directory,
# owner => "root",
# group => "root",
# mode => "0644";
#
# "/etc/httpd/conf.d/katello.d/katello.conf":
# content => template("katello/etc/httpd/conf.d/katello.d/katello.conf.erb"),
# owner => "root",
# group => "root",
# mode => "0644";
}

}
70 changes: 70 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# == Class: katello
#
# Install and configure katello
#
# === Parameters:
#
# $user:: The Katello system user name;
# default 'katello'
#
# $group:: The Katello system user group;
# default 'katello'
#
# $user_groups:: Extra user groups the Katello user is a part of;
# default 'foreman
#
# $oauth_key:: The oauth key for talking to the candlepin API;
# default 'katello'
#
# $oauth_secret:: The oauth secret for talking to the candlepin API;
#
# $log_dir:: Location for Katello log files to be placed
#
class katello (

$user = $katello::params::user,
$group = $katello::params::group,
$user_groups = $katello::params::user_groups,

$oauth_key = $katello::params::oauth_key,
$oauth_secret = $katello::params::oauth_secret,

$log_dir = $katello::params::log_dir

) inherits katello::params {

group { $katello::group:
ensure => "present"
}

user { $katello::user:
ensure => 'present',
shell => '/sbin/nologin',
comment => 'Katello',
gid => $katello::group,
groups => $katello::user_groups,
require => Class['katello::install'],
}

class{ 'katello::install': } ->
class{ 'katello::config::files': } ~>
class{ 'certs':
log_dir => $katello::log_dir
} ~>
class{ 'candlepin':
user_groups => $katello::user_groups,
oauth_key => $katello::oauth_key,
oauth_secret => $katello::oauth_secret,
deployment_url => 'katello',
before => Exec['foreman-rake-db:seed']
} ~>
class{ 'pulp':
oauth_key => $katello::oauth_key,
oauth_secret => $katello::oauth_secret,
before => Exec['foreman-rake-db:seed']
} ~>
class{ 'elasticsearch':
before => Exec['foreman-rake-db:seed']
}

}
74 changes: 74 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
class katello::install {

$os = $operatingsystem ? {
"RedHat" => "RHEL",
"CentOS" => "RHEL",
default => "Fedora"
}

$package = $os ? {
'RHEL' => 'ruby193-rubygem-katello',
'Fedora' => 'rubygem-katello'
}

package{[$package]:
ensure => installed,
}

# include katello
#
# include candlepin::install
# include postgres::install
# include apache2::install
#
# # Headpin does not care about pulp
# case $katello::params::deployment {
# 'katello': {
# include pulp::install
# include qpid::install
# }
# 'headpin': {
# include thumbslug::install
# }
# default : {}
# }
#
# $os = $operatingsystem ? {
# "RedHat" => "RHEL",
# "CentOS" => "RHEL",
# default => "Fedora"
# }
#
# yumrepo { "katello-nightly":
# name => "katello-nightly",
# baseurl => "http://fedorapeople.org/groups/katello/releases/yum/nightly/${os}/${lsbmajdistrelease}/x86_64/",
# enabled => "1",
# gpgcheck => "0"
# }
#
# yumrepo { "katello-nightly-source":
# name => "katello-nightly-source",
# baseurl => "http://fedorapeople.org/groups/katello/releases/source/nightly/${os}/${lsbmajdistrelease}/x86_64/",
# enabled => "0",
# gpgcheck => "0"
# }
#
# package {["katello", "katello-cli"]:
# require => $katello::params::deployment ? {
# 'katello' => [Yumrepo["katello-nightly"],Class["pulp::install"],Class["candlepin::install"]],
# 'headpin' => [Yumrepo["katello-nightly"],Class["candlepin::install"],Class["thumbslug::install"]],
# default => []
# },
# before => $katello::params::deployment ? {
# 'katello' => [Class["candlepin::config"], Class["pulp::config"] ], #avoid some funny post rpm scripts
# 'headpin' => [Class["candlepin::config"], Class["thumbslug::config"]], #avoid some funny post rpm scripts
# default => []
# },
# ensure => installed
# }
#
# Class["katello::install"] -> File["${katello::params::log_base}"]
# Class["katello::install"] -> File["${katello::params::config_dir}/thin.yml"]
# Class["katello::install"] -> File["${katello::params::config_dir}/katello.yml"]
# Class["katello::install"] -> File["/etc/httpd/conf.d/katello.conf"]
}
Loading

0 comments on commit ae7d4aa

Please sign in to comment.