be09d2bcda
If you attempt to include both Zuul and Jenkins master modules in a single manifest, you will get an error about A2mod[rewrite] resource already being declared, like so: Duplicate declaration: A2mod[rewrite] is already declared in file /home/ubuntu/os-ext-testing/puppet/modules/os_ext_testing/manifests/master.pp at line 30; cannot redeclare at /root/config/modules/zuul/manifests/init.pp:236 on node undef This isn't noticed by upstream, because no server runs both a Jenkins master and a Zuul server. However, in smaller systems, where both Jenkins and Zuul can be installed on the same host, the problem becomes apparent. This patch fixes that issue by adding guards around the a2mod declarations in the Zuul init.pp and Jenkins master.pp manifests. Change-Id: I2a298eb09ec8da33caed9349f465b2d163e2c299 Closes-bug: #1281676
231 lines
5.7 KiB
Puppet
231 lines
5.7 KiB
Puppet
# == Class: jenkins::master
|
|
#
|
|
class jenkins::master(
|
|
$logo = '',
|
|
$vhost_name = $::fqdn,
|
|
$serveradmin = "webmaster@${::fqdn}",
|
|
$ssl_cert_file = '',
|
|
$ssl_key_file = '',
|
|
$ssl_chain_file = '',
|
|
$ssl_cert_file_contents = '', # If left empty puppet will not create file.
|
|
$ssl_key_file_contents = '', # If left empty puppet will not create file.
|
|
$ssl_chain_file_contents = '', # If left empty puppet will not create file.
|
|
$jenkins_ssh_private_key = '',
|
|
$jenkins_ssh_public_key = '',
|
|
) {
|
|
include pip
|
|
include apt
|
|
include apache
|
|
|
|
package { 'openjdk-7-jre-headless':
|
|
ensure => present,
|
|
}
|
|
|
|
package { 'openjdk-6-jre-headless':
|
|
ensure => purged,
|
|
require => Package['openjdk-7-jre-headless'],
|
|
}
|
|
|
|
#This key is at http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key
|
|
apt::key { 'jenkins':
|
|
key => 'D50582E6',
|
|
key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
|
|
require => Package['wget'],
|
|
}
|
|
|
|
apt::source { 'jenkins':
|
|
location => 'http://pkg.jenkins-ci.org/debian',
|
|
release => 'binary/',
|
|
repos => '',
|
|
require => [
|
|
Apt::Key['jenkins'],
|
|
Package['openjdk-7-jre-headless'],
|
|
],
|
|
include_src => false,
|
|
}
|
|
|
|
apache::vhost { $vhost_name:
|
|
port => 443,
|
|
docroot => 'MEANINGLESS ARGUMENT',
|
|
priority => '50',
|
|
template => 'jenkins/jenkins.vhost.erb',
|
|
ssl => true,
|
|
}
|
|
if ! defined(A2mod['rewrite']) {
|
|
a2mod { 'rewrite':
|
|
ensure => present,
|
|
}
|
|
}
|
|
if ! defined(A2mod['proxy']) {
|
|
a2mod { 'proxy':
|
|
ensure => present,
|
|
}
|
|
}
|
|
if ! defined(A2mod['proxy_http']) {
|
|
a2mod { 'proxy_http':
|
|
ensure => present,
|
|
}
|
|
}
|
|
|
|
if $ssl_cert_file_contents != '' {
|
|
file { $ssl_cert_file:
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0640',
|
|
content => $ssl_cert_file_contents,
|
|
before => Apache::Vhost[$vhost_name],
|
|
}
|
|
}
|
|
|
|
if $ssl_key_file_contents != '' {
|
|
file { $ssl_key_file:
|
|
owner => 'root',
|
|
group => 'ssl-cert',
|
|
mode => '0640',
|
|
content => $ssl_key_file_contents,
|
|
require => Package['ssl-cert'],
|
|
before => Apache::Vhost[$vhost_name],
|
|
}
|
|
}
|
|
|
|
if $ssl_chain_file_contents != '' {
|
|
file { $ssl_chain_file:
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0640',
|
|
content => $ssl_chain_file_contents,
|
|
before => Apache::Vhost[$vhost_name],
|
|
}
|
|
}
|
|
|
|
$packages = [
|
|
'python-babel',
|
|
'python-sqlalchemy', # devstack-gate
|
|
'ssl-cert',
|
|
'sqlite3', # interact with devstack-gate DB
|
|
]
|
|
|
|
package { $packages:
|
|
ensure => present,
|
|
}
|
|
|
|
package { 'jenkins':
|
|
ensure => present,
|
|
require => Apt::Source['jenkins'],
|
|
}
|
|
|
|
exec { 'update apt cache':
|
|
subscribe => File['/etc/apt/sources.list.d/jenkins.list'],
|
|
refreshonly => true,
|
|
path => '/bin:/usr/bin',
|
|
command => 'apt-get update',
|
|
}
|
|
|
|
file { '/var/lib/jenkins':
|
|
ensure => directory,
|
|
owner => 'jenkins',
|
|
group => 'adm',
|
|
require => Package['jenkins'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/.ssh/':
|
|
ensure => directory,
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
mode => '0700',
|
|
require => File['/var/lib/jenkins'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/.ssh/id_rsa':
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
mode => '0600',
|
|
content => $jenkins_ssh_private_key,
|
|
replace => true,
|
|
require => File['/var/lib/jenkins/.ssh/'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/.ssh/id_rsa.pub':
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
mode => '0644',
|
|
content => $jenkins_ssh_public_key,
|
|
replace => true,
|
|
require => File['/var/lib/jenkins/.ssh/'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/plugins':
|
|
ensure => directory,
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
mode => '0750',
|
|
require => File['/var/lib/jenkins'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/plugins/simple-theme-plugin':
|
|
ensure => directory,
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
require => File['/var/lib/jenkins/plugins'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/plugins/simple-theme-plugin/openstack.css':
|
|
ensure => present,
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
source => 'puppet:///modules/jenkins/openstack.css',
|
|
require => File['/var/lib/jenkins/plugins/simple-theme-plugin'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/plugins/simple-theme-plugin/openstack.js':
|
|
ensure => present,
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
content => template('jenkins/openstack.js.erb'),
|
|
require => File['/var/lib/jenkins/plugins/simple-theme-plugin'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/plugins/simple-theme-plugin/openstack-page-bkg.jpg':
|
|
ensure => present,
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
source => 'puppet:///modules/jenkins/openstack-page-bkg.jpg',
|
|
require => File['/var/lib/jenkins/plugins/simple-theme-plugin'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/logger.conf':
|
|
ensure => present,
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
source => 'puppet:///modules/jenkins/logger.conf',
|
|
require => File['/var/lib/jenkins'],
|
|
}
|
|
|
|
file { '/var/lib/jenkins/plugins/simple-theme-plugin/title.png':
|
|
ensure => present,
|
|
owner => 'jenkins',
|
|
group => 'nogroup',
|
|
source => "puppet:///modules/jenkins/${logo}",
|
|
require => File['/var/lib/jenkins/plugins/simple-theme-plugin'],
|
|
}
|
|
|
|
file { '/usr/local/jenkins':
|
|
ensure => directory,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0755',
|
|
}
|
|
|
|
file { '/usr/local/jenkins/slave_scripts':
|
|
ensure => directory,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0755',
|
|
recurse => true,
|
|
purge => true,
|
|
force => true,
|
|
require => File['/usr/local/jenkins'],
|
|
source => 'puppet:///modules/jenkins/slave_scripts',
|
|
}
|
|
}
|