Skip to content

Commit 1a2dd48

Browse files
author
Tim Meusel
committed
1 parent 555b7e0 commit 1a2dd48

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

manifests/master.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
# ['listen_address'] - IP for binding the webserver, defaults to *
3737
# ['disable_ssl'] - Disables SSL on the webserver. usefull if you use this master behind a loadbalancer. currently only supported by nginx, defaults to undef
3838
# ['backup_upstream'] - specify another puppet master as fallback. currently only supported by nginx
39+
# ['unicorn_path'] - custom path to the unicorn binary
3940
#
4041
# Requires:
4142
#
@@ -91,6 +92,7 @@
9192
$listen_address = $::puppet::params::listen_address,
9293
$disable_ssl = $::puppet::params::disable_ssl,
9394
$backup_upstream = $::puppet::params::backup_upstream,
95+
$unicorn_path = $::puppet::params::unicorn_path,
9496
) inherits puppet::params {
9597

9698
anchor { 'puppet::master::begin': }

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
$default_webserver = 'httpd'
3636
$disable_ssl = undef
3737
$backup_upstream = []
38+
$unicorn_path = '/usr/local/bin/unicorn'
3839

3940
# Only used when environments == directory
4041
$environmentpath = '$confdir/environments'

manifests/unicorn.pp

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# ['puppet_proxy_port'] - The port for the virtual host
66
# ['disable_ssl'] - Disables SSL on the webserver. usefull if you use this master behind a loadbalancer. currently only supported by nginx, defaults to undef
77
# ['backup_upstream'] - specify another puppet master as fallback. currently only supported by nginx
8+
# ['unicorn_package'] - package name of a unicorn rpm. if provided we install it, otherwise we built it via gem/gcc
9+
# ['unicorn_path'] - custom path to the unicorn binary
810
#
911
# Actions:
1012
# - Configures nginx and unicorn for puppet master use. Tested only on CentOS 7
@@ -26,45 +28,54 @@
2628
$puppet_proxy_port,
2729
$disable_ssl,
2830
$backup_upstream,
31+
$unicorn_package,
32+
$unicorn_path,
2933
){
3034
include nginx
31-
# install unicorn
32-
unless defined(Package['ruby-devel']) {
33-
package {'ruby-devel':
35+
36+
# if this is provided we install the package from the repo, otherwise we build unicorn from scratch
37+
if $unicorn_package {
38+
package {$unicorn_package:
39+
ensure => 'latest',
40+
}
41+
} else {
42+
# install unicorn
43+
unless defined(Package['ruby-devel']) {
44+
package {'ruby-devel':
45+
ensure => 'latest',
46+
}
47+
}
48+
package {'gcc':
3449
ensure => 'latest',
50+
} ->
51+
package {['unicorn', 'rack']:
52+
ensure => 'latest',
53+
provider => 'gem',
54+
require => Package['ruby-devel'],
3555
}
3656
}
37-
package {'gcc':
38-
ensure => 'latest',
39-
} ->
40-
package {['unicorn', 'rack']:
41-
ensure => 'latest',
42-
provider => 'gem',
43-
require => Package['ruby-devel'],
57+
file {'unicorn-conf':
58+
path => '/etc/puppet/unicorn.conf',
59+
source => 'puppet:///modules/puppet/unicorn.conf',
4460
} ->
4561
file {'copy-config':
4662
path => '/etc/puppet/config.ru',
4763
source => '/usr/share/puppet/ext/rack/config.ru',
4864
} ->
49-
file {'unicorn-conf':
50-
path => '/etc/puppet/unicorn.conf',
51-
source => 'puppet:///modules/puppet/unicorn.conf',
65+
exec{'systemd-reload':
66+
command => '/usr/bin/systemctl daemon-reload',
67+
refreshonly => true,
68+
notify => Service['unicorn-puppetmaster'],
5269
} ->
5370
file {'unicorn-service':
5471
path => '/usr/lib/systemd/system/unicorn-puppetmaster.service',
55-
source => 'puppet:///modules/puppet/unicorn-puppetmaster.service',
72+
source => template('puppet/unicorn-puppetmaster.service'),
5673
notify => Exec['systemd-reload'],
5774
} ->
58-
exec{'systemd-reload':
59-
command => '/usr/bin/systemctl daemon-reload',
60-
refreshonly => true,
61-
notify => Service['unicorn-puppetmaster'],
62-
}
6375
unless defined(Service['unicorn-puppetmaster']) {
6476
service{'unicorn-puppetmaster':
6577
ensure => 'running',
6678
enable => true,
67-
require => Exec['systemd-reload'],
6879
}
6980
}
7081
# update SELinux

files/unicorn-puppetmaster.service renamed to templates/unicorn-puppetmaster.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Description=Puppet master served by Unicorn
33

44
[Service]
5-
ExecStart=/usr/local/bin/unicorn -c /etc/puppet/unicorn.conf
5+
ExecStart=<% @unicorn_path %> -c /etc/puppet/unicorn.conf
66
ExecReload=/usr/bin/kill -s HUP $MAINPID
77
PrivateTmp=yes
88
# this would be cool, but then the puppetmaster can't reach the puppetdb

0 commit comments

Comments
 (0)