Skip to content

Instantly share code, notes, and snippets.

@tzachz
Last active December 14, 2015 07:18
Show Gist options
  • Save tzachz/5049339 to your computer and use it in GitHub Desktop.
Save tzachz/5049339 to your computer and use it in GitHub Desktop.
Dropwizard service puppet code
# sets up a dropwizard-based service packaged as debian
# requires: puppetlabs-apt, puppetlabs-stdlib
class sample-dw-service (
$version='latest', # you can pass a specified version, default is latest
$db_url='' # this is how you pass environment-specific configuration - in this case, a DB URL
) {
# refresh apt
notify { "refreshing apt":
notify => Class['apt::update'],
}
# add your deb repository location so that apt can find your package
apt::source { 'sample-dw-service':
location => 'http://your.debian.repo/',
release => '/',
repos => '',
include_src => false,
}
# install the package
package { 'sample-dw-service' :
ensure => $version,
require => [Apt::Source['sample-dw-service'], Class['apt::update']],
notify => Service["sample-dw-service"],
}
# create user group
group { "dw-user":
ensure => present,
}
# create user
user { "dw-user":
ensure => present,
gid => 'dw-user',
shell => '/bin/bash',
require => Group["dw-user"]
}
# start the service
service { "sample-dw-service":
ensure => running,
enable => true,
provider => upstart,
require => [Package['sample-dw-service'], File["conf-file"]]}
# create directory for configuration file
file { "conf-dir":
path => "/etc/sample-dw-service",
ensure => "directory",
}
# create configuration file - write the input parameter $db_url into the file
file { "conf-file":
path => "/etc/sample-dw-service/server.cfg",
mode => 644,
ensure => file,
content => "database.url=$db_url",
require => File["conf-dir"],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment