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

Add Debian #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
artifactory: "#{source_dir}"
9 changes: 0 additions & 9 deletions Modulefile

This file was deleted.

38 changes: 14 additions & 24 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
class artifactory($jdk = "java-1.7.0-openjdk",
$sourceforge = "http://downloads.sourceforge.net/project",
$version = "3.0.1") {

# http://downloads.sourceforge.net/project/artifactory/artifactory/2.5.1.1/artifactory-2.5.1.1.rpm

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]
}

service { 'artifactory':
ensure => 'running',
enable => "true",
hasstatus => "false",
provider => "redhat",
require => Package['artifactory']
}
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

) inherits artifactory::params {
anchor { '::artifactory::start': } ->
class { '::artifactory::user': } ->
class { '::artifactory::install': } ->
class { '::artifactory::service': } ->
anchor { '::artifactory::end': }
}
48 changes: 48 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class artifactory::install inherits artifactory {

if $::osfamily == 'Debian' {

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

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 => $extracted,
target => $artifactory::app_dir,
user => $artifactory::username,
group => $artifactory::username
}
-> file { "${artifactory::app_dir}/current":
ensure => link,
target => $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",
}
}

}
11 changes: 11 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +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'
$app_version = '3.3.0'
}
29 changes: 29 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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']
}
}

}
13 changes: 13 additions & 0 deletions manifests/user.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class artifactory::user inherits artifactory {

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

user { $artifactory::username:
ensure => present,
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