Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Add Debian support to the Puppet Module
Browse files Browse the repository at this point in the history
Minor changes after running puppet-lint
  • Loading branch information
mukaibot committed Aug 21, 2014
1 parent 8ed9519 commit f6d0f80
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 57 deletions.
9 changes: 0 additions & 9 deletions Modulefile

This file was deleted.

24 changes: 9 additions & 15 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
class artifactory { #($jdk = "java-1.7.0-openjdk",
#$sourceforge = "http://downloads.sourceforge.net/project",
#$version = "3.0.1") {
class artifactory (
$username = $artifactory::params::username,
$pass_hash = $artifactory::params::pass_hash,
$manage_java = $artifactory::params::manage_java,
$java_version = $artifactory::params::java_version,
$app_dir = $artifactory::params::app_dir,
$app_data = $artifactory::params::app_data,
$app_version = $artifactory::params::app_version

#if ! defined (Package[$jdk]) {
# package { $jdk: ensure => installed }
#}

package { 'artifactory':
ensure => installed,
provider => "rpm",
source => "$sourceforge/artifactory/artifactory/$version/artifactory-$version.rpm",
require => Package[$jdk]
}

} inherits artifactory::params {
) inherits artifactory::params {
anchor { '::artifactory::start': } ->
class { '::artifactory::user': } ->
class { '::artifactory::install': } ->
Expand Down
58 changes: 43 additions & 15 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
class artifactory::install inherits artifactory {
$url = "http://dl.bintray.com/jfrog/artifactory/artifactory-${app_version}.zip"

if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

staging::deploy { "artifactory-${app_version}.zip":
source => $url,
target => $app_dir,
creates => "$app_dir/artifactory-${app_version}"
}
if $::osfamily == 'Debian' {

$url = "http://dl.bintray.com/jfrog/artifactory/artifactory-${artifactory::app_version}.zip"
$artifactory::extracted = "${artifactory::app_dir}/artifactory-${artifactory::app_version}"

file { $app_data:
ensure => directory,
mode => '0755',
owner => $username,
group => $username
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

file { $artifactory::app_data:
ensure => directory,
mode => '0755',
owner => $artifactory::username,
group => $artifactory::username
}
-> file { $artifactory::app_dir:
ensure => directory,
mode => '0755',
owner => $artifactory::username,
group => $artifactory::username
}
-> staging::deploy { "artifactory-${artifactory::app_version}.zip":
source => $url,
creates => $artifactory::extracted,
target => $artifactory::app_dir,
user => $artifactory::username,
group => $artifactory::username
}
-> file { "${artifactory::app_dir}/current":
ensure => link,
target => $artifactory::extracted
}
-> file { "${artifactory::app_dir}/current/data":
ensure => link,
target => $artifactory::app_data
}

} elsif $::osfamily == 'RedHat' {
package { 'artifactory':
ensure => installed,
provider => 'rpm',
source => "http://downloads.sourceforge.net/project/artifactory/artifactory/${artifactory::app_version}/artifactory-${artifactory::app_version}.rpm",
}
}

}
12 changes: 6 additions & 6 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# == Class Artifactory::Params
# Contains all the parameters for the Artifactory module
class artifactory::params {
$username = 'artifactory',
$pass_hash = undef,
$manage_java = false,
$java_version = '7',
$app_dir = '/opt/artifactory',
$app_data = '/var/artifactory',
$username = 'artifactory'
$pass_hash = undef
$manage_java = false
$java_version = '7'
$app_dir = '/opt/artifactory'
$app_data = '/var/artifactory'
$app_version = '3.3.0'
}
36 changes: 27 additions & 9 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
class artifactory::server inherits artifactory {

# service { 'artifactory':
# ensure => 'running',
# enable => "true",
# hasstatus => "false",
# provider => "redhat",
# require => Package['artifactory']
# }
class artifactory::service inherits artifactory {

if $::osfamily == 'Debian' {

file { '/etc/init.d/artifactory':
ensure => present,
content => template('artifactory/artifactory.Debian.init.erb'),
owner => root,
group => root,
mode => '0755'
}
-> service { 'artifactory':
ensure => 'running',
provider => 'debian',
enable => true,
}

} elsif $::osfamily == 'RedHat' {

service { 'artifactory':
ensure => 'running',
enable => true,
hasstatus => false,
provider => 'redhat',
require => Package['artifactory']
}
}

}
7 changes: 4 additions & 3 deletions manifests/user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

user { $username:
user { $artifactory::username:
ensure => present,
manage_home => false,
password => $pass_hash
managehome => true,
home => $artifactory::app_data,
password => $artifactory::pass_hash
}
}
52 changes: 52 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "maestrodev-artifactory",
"version": "1.0.1",
"author": "maestrodev",
"summary": "A really simple module to install Artifactory",
"license": "Apache License, Version 2.0",
"source": "http://github.com/maestrodev/puppet-artifactory",
"project_page": "http://github.com/maestrodev/puppet-artifactory",
"issues_url": "https://github.com/maestrodev/puppet-artifactory/issues",
"description": "Installs Artifactory package and service",
"requirements": [
{
"name": "pe",
"version_requirement": ">=3.2.0 <3.4.0"
},
{
"name": "puppet",
"version_requirement": ">=3.0.0 <4.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystem_release": [
"6"
]
},
{
"operatingsystem": "Centos",
"operatingsystem_release": [
"6"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystem_release": [
"12.04",
"14.04"
]
}
],
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">=4.0.0 <5.0.0"
},
{
"name": "nanliu/staging",
"version_requirement": ">=0.4.1 <1.0.0"
}
]
}
81 changes: 81 additions & 0 deletions templates/artifactory.Debian.init.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

### BEGIN INIT INFO
# Provides: artifactory
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop artifactory
# Description: Artifactory is an artifact management server, written by JFrog
### END INIT INFO

RETVAL=0
LOCKFILE=/var/lock/artifactory
logfile=/var/log/artifactory
artifactory_dir=<%= @app_dir %>/current
artifactory_data=<%= @app_data %>
user=<%= @username %>
DAEMON_START="$artifactory_dir/bin/artifactory.sh"
DAEMON_STOP="$artifactory_dir/tomcat/bin/catalina.sh"
DAEMON_ARGS="start"

start() {
export CATALINA_OUT=$logfile
export ARTIFACTORY_HOME=$artifactory_data

if [ -e $LOCKFILE ]
then
echo "$LOCKFILE exists, Artifactory already running"
exit 1
fi

if [ -e '/etc/default/artifactory' ]
then
source /etc/default/artifactory
fi

touch $LOCKFILE
touch $logfile
chown $user $logfile
echo "Starting Artifactory"
start-stop-daemon -c $user --start --quiet --exec $DAEMON_START $DAEMON_ARGS > /dev/null || return 1
}

stop() {
echo "Stopping Artifactory"
rm $LOCKFILE
su -l $user -c "$DAEMON_STOP stop" > /dev/null
rm $PIDFILE
}

status() {
PIDFILE=$artifactory_dir/run/artifactory.pid
if [ -e $LOCKFILE ] && [ -e $PIDFILE ]
then
pid=`cat $PIDFILE`
echo "Artifactory is running with pid $pid"
else
echo "Artifactory is stopped"
fi
}


case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
esac

0 comments on commit f6d0f80

Please sign in to comment.