Skip to content

Commit

Permalink
refactor module to use Hiera databindings. Use parameterized class.
Browse files Browse the repository at this point in the history
See README file / class documentation.
  • Loading branch information
mkrakowitzer committed Jun 4, 2013
1 parent 58786a3 commit 508a427
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 195 deletions.
11 changes: 11 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name 'brycejohnson-jira'
version '0.0.2'
source 'https://github.com/brycejohnson/puppet-jira.git'
author 'brycejohnson'
license 'Apache License, Version 2.0'
summary 'Module to install Jira'
description 'Module to install Jira'
project_page 'https://github.com/brycejohnson/puppet-jira/blob/master/README.md'

## Add dependencies, if any:
dependency 'mkrakowitzer/deploy', '>= 0.0.1'
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,20 @@ variables are then defined in the module's `params.pp`.

### Puppet

Puppet 3.0+ is required as this module leverages hiera

Puppet itself requires:

* ruby
* rubygems
* Ruby Augeas http://pkgs.repoforge.org/ruby-augeas/
* Ruby Shadow http://pkgs.repoforge.org/ruby-shadow/
* Ruby JSON http://pkgs.repoforge.org/ruby-json/

Hiera requires that you build a `hiera.yaml` configuration file in `/etc/puppet`
Tested on Puppet 3.0+
Puppet 2.7+ should work as Hiera is now optional.

The puppetlabs production yum repository can be found at:
http://yum.puppetlabs.com/el/6/products/x86_64

### Operating Systems
* MacOS: UNSUPPORTED
* Linux: RedHat (Debian untested)
* Windows: UNSUPPORTED
* Linux: RedHat / Centos 5/6 - tested.
* Linux: Ubuntu 12.04 - tested.

### Databases
* Postgres
* MySQL (untested)


### Before you begin
It is your responsibility to backup your database. Especially do so
if you are installing to an existing installation of jira as this module
Expand All @@ -54,7 +43,6 @@ I have my own postgres puppet module that installs pg, creates the JIRA
database, and the JIRA database user before the JIRA puppet module runs.

Make sure you have a JAVA_HOME and appropriate java installed on your machine.
Recommended is JDK 1.6u33+ and not JDK 1.7+

Did I mention if you are upgrading, BACKUP your database first? This module
makes no warranty on your data, per its license.
Expand All @@ -63,15 +51,26 @@ makes no warranty on your data, per its license.

This puppet module will automatically download the jira zip from Atlassian
and extract it into /opt/jira/atlassian-jira-$version

This module requires: https://github.com/mkrakowitzer/puppet-deploy.git

You will also need to enter in the directory to your jira-home, which should
also be kept in the hiera yaml, for example {{jira.yaml}}.

Once you have installed the yaml information, then run puppet apply with
this module included in the modulepath.

An example on how to use this module:

class { 'jira':
version => '6.0.1',
installdir => '/opt/atlassian-jira',
homedir => '/opt/atlassian-jira/jira-home',
user => 'jira',
group => 'jira',
dbpassword => 'secret',
dbserver => 'localhost',
javahome => '/opt/java/jdk1.7.0_21/',
downloadURL => 'http://myserver/pub/development-tools/atlassian/',
}

If you would prefer to use Hiera then see jira.yaml file for an example.

### Fixes and Future Work
Please feel free to raise any issues here for fixes. I'm happy to fix them
up. Also feel free to make a pull request for anything so I can hopefully
get it in.

48 changes: 28 additions & 20 deletions jira.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,59 @@
# 2.) Modify the database settings below according to your setup
#
# Atlassian jira Git Enterprise Source Control Server
jira_name: jira
jira_version: 5.1.7
jira_package_format: zip
jira::jira_name: jira
jira::jira_version: 5.1.7
jira::jira_package_format: tar.gz

# Directory where the webapp will run from
jira_install_dir: /opt/jira
jira::jira_install_dir: /opt/jira
# If you can put this on another filesystem, and even better, a fs that's
# on another physical disk, you will be happier, but not required
jira_home_dir: /opt/jira-home
jira::jira_home_dir: /opt/jira-home
# What user should jira run as
# Puppet will make the user
jira::user: jira
jira::group: jira

# Database configuration - please change these according to your setup
# Comment out or uncomment for your db product as this value is also
# overloaded as the jdbc driver db
jira_db: postgresql
#jira_db: mysql
#jira_db: oracle
jira::jira_db: postgresql
#jira::jira_db: mysql
#jira::jira_db: oracle

jira_dbtype: postgres72
jira::jira_dbtype: postgres72
#jira_dbtype: mysql

jira_dbdriver: org.postgresql.Driver
jira::jira_dbdriver: org.postgresql.Driver
#jira_dbdriver: com.mysql.jdbc.Driver

# Change these values to your jira database credentials
jira_dbuser: jiraadm
jira_dbpassword: jiraadm
jira::jira_dbuser: jiraadm
jira::jira_dbpassword: jiraadm

jira_dbname: jira
jira::jira_dbname: jira
# Change port depending on your db product
jira_dbport: 5432
#jira_dbport: 3306
#jira_dbport: 1521
jira::jira_dbport: 5432
#jira::jira_dbport: 3306
#jira::jira_dbport: 1521

# The connection pool size
jira::poolsize: 15

# Change if your database isn't on localhost. This module will only check
# to make sure that the service is running and start it if it is not on
# localhost db's only. So if your remote database, which is suggested, isn't
# available, that's your fault.
jira_dbserver: localhost
jira::jira_dbserver: localhost

# Tomcat configuration
# TODO because I'm never a fan of the stock tomcat settings
jira_javahome: /opt/java/jdk1.6.0_33
jira_jvm_xmx: 1024m
jira_jvm_optional: -XX:-HeapDumpOnOutOfMemoryError
jira::jira_javahome: /opt/java/jdk1.6.0_33
jira::jira_jvm_xmx: 1024m
jira::jira_jvm_optional: -XX:-HeapDumpOnOutOfMemoryError
#jira_jvm_optional: -XX:NewSize=256m -XX:MaxNewSize=256m -XX:SurvivorRatio=16
# the New and SR figures are purely optional
# for heap dumps add -XX:-HeapDumpOnOutOfMemoryError
# by default jira has 256m permgen which is a good setting to go with
jira::downloadURL: "http://www.atlassian.com/software/jira/downloads/binary/"
50 changes: 25 additions & 25 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------------
class jira::config{
class jira::config {

require jira::params
require jira

exec { 'mkdirp-homedir-jira':
cwd => "${jira::params::tmpdir}",
command => "/bin/mkdir -p ${jira::params::homedir}",
creates => "${jira::params::homedir}"
File {
owner => $jira::user,
group => $jira::group,
}

file { "${jira::params::webappdir}/bin/setenv.sh":
file { "${jira::webappdir}/bin/user.sh":
content => template('jira/user.sh.erb'),
mode => '0755',
require => [
Class['jira::install'],
File[$jira::webappdir],
File[$jira::homedir]
],
} ->

file { "${jira::webappdir}/bin/setenv.sh":
content => template('jira/setenv.sh.erb'),
mode => '0755',
require => Class['jira::install'],
notify => Class['jira::service'],
} ->

file { "${jira::homedir}/dbconfig.xml":
content => template("jira/dbconfig.${jira::db}.xml.erb"),
mode => '0600',
require => [ Class['jira::install'],File[$jira::homedir] ],
notify => Class['jira::service'],
}

if "${jira::params::db}" == 'postgresql' {
file { "${jira::params::homedir}/dbconfig.xml":
content => template('jira/dbconfig.postgres.xml.erb'),
mode => '0600',
require => [Class['jira::install'],Exec['mkdirp-homedir-jira']],
notify => Class['jira::service'],
}
}
if "${jira::params::db}" == 'mysql' {
file { "${jira::params::homedir}/dbconfig.xml":
content => template('jira/dbconfig.mysql.xml.erb'),
mode => '0600',
require => [Class['jira::install'],Exec['mkdirp-homedir-jira']],
notify => Class['jira::service'],
}
}
}

}
73 changes: 71 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,79 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------------
# == Class: jira
#
# This module is used to install Jira.
# I have tested it with version 6.0 and upgarded to 6.0.1 succesfully.
#
# This module requires mkrakowitzer-deploy
#
# === Parameters
#
# See jira.yaml for a complete list of parameters
#
# === Examples
#
# class { 'jira':
# version => '6.0.1',
# installdir => '/opt/atlassian/atlassian-jira',
# homedir => '/opt/atlassian/atlassian-jira/jira-home',
# user => 'jira',
# group => 'jira',
# dbpassword => 'mysecret',
# dbserver => 'devecodb1',
# javahome => '/opt/development-tools/java/jdk1.7.0_21/',
# downloadURL => 'http://myurl/pub/software/atlassian/',
# }
#
# === Authors
#
# Bryce Johnson
# Merritt Krakowitzer
#
# === Copyright
#
# Copyright (c) 2012 Bryce Johnson
#
# Published under the Apache License, Version 2.0
#
class jira (

# JVM Settings
$javahome,
$jvm_xmx = '1024m',
$jvm_optional = '-XX:-HeapDumpOnOutOfMemoryError',

# Jira Settings
$version = '6.0',
$product = 'jira',
$format = 'tar.gz',
$installdir = '/opt/jira',
$homedir = '/home/jira',
$user = 'root',
$group = 'root',

# Database Settings
$db = 'postgresql',
$dbuser = 'jiraadm',
$dbpassword = 'mypassword',
$dbserver = 'localhost',
$dbname = 'jira',
$dbport = '5432',
$dbdriver = 'org.postgresql.Driver',
$dbtype = 'postgres72',
$poolsize = '15',

# Misc Settings
$downloadURL = 'http://www.atlassian.com/software/jira/downloads/binary/',

) {

$webappdir = "${installdir}/atlassian-${product}-${version}-standalone"
$dburl = "jdbc:${db}://${dbserver}:${dbport}/${dbname}"

class jira {
include jira::params
include jira::install
include jira::config
include jira::service

}
60 changes: 31 additions & 29 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,41 @@
#-----------------------------------------------------------------------------
class jira::install {

require jira::params
require jira

case $::osfamily {
'Darwin' : { # assuming you did download wget - ill maybe fix this and check for it
exec { 'wget-jira-package':
cwd => "${jira::params::tmpdir}",
command => "${jira::params::cmdwget} --no-check-certificate ${jira::params::downloadURL}",
creates => "${jira::params::tmpdir}/atlassian-${jira::params::product}-${jira::params::version}.${jira::params::format}",
}
}
default : {
exec { 'wget-jira-package':
cwd => "${jira::params::tmpdir}",
command => "${jira::params::cmdwget} --no-check-certificate ${jira::params::downloadURL}",
creates => "${jira::params::tmpdir}/atlassian-${jira::params::product}-${jira::params::version}.${jira::params::format}",
}
}
}
deploy::file { "atlassian-${jira::product}-${jira::version}.${jira::format}":
target => "${jira::installdir}/atlassian-${jira::product}-${jira::version}-standalone",
url => $jira::downloadURL,
strip => true,
notify => Exec["chown_${jira::webappdir}"],
} ->

exec { 'mkdirp-installdir-jira':
cwd => "${jira::params::tmpdir}",
command => "/bin/mkdir -p ${jira::params::installdir}",
creates => "${jira::params::installdir}",
}
exec { 'unzip-jira-package':
cwd => "${jira::params::installdir}",
command => "/usr/bin/unzip -o -d ${jira::params::installdir} ${jira::params::tmpdir}/atlassian-${jira::params::product}-${jira::params::version}.${jira::params::format}",
creates => "${jira::params::webappdir}",
require => [Exec['wget-jira-package'],Exec['mkdirp-installdir-jira']],
}
user { $jira::user:
comment => 'Jira daemon account',
shell => '/bin/true',
home => $jira::homedir,
password => '*',
password_min_age => '0',
password_max_age => '99999',
managehome => true,
} ->

file { '/etc/rc.d/init.d/jira':
file { $jira::homedir:
ensure => 'directory',
owner => 'jira',
group => 'jira',
recurse => true,
} ->

exec { "chown_${jira::webappdir}":
command => "/bin/chown -R ${jira::user}:${jira::group} ${jira::webappdir}",
refreshonly => true,
subscribe => User[$jira::user]
} ->

file { '/etc/init.d/jira':
content => template('jira/etc/rc.d/init.d/jira.erb'),
mode => '0755',
}

}
Loading

0 comments on commit 508a427

Please sign in to comment.