forked from bobtfish/puppet-omnibus
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrecipe.rb
117 lines (94 loc) · 2.76 KB
/
recipe.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# TODO: fix this upstream
class FPM::Cookery::Path
def encoding
@encoding ||= Encoding.find("filesystem")
end
end
class FPM::Cookery::Recipe
alias :old_cachedir :cachedir
def cachedir(*args)
path = ENV['FPM_CACHE_DIR']
path ? FPM::Cookery::Path.new(path) : old_cachedir(*args)
end
end
class PuppetOmnibus < FPM::Cookery::Recipe
homepage 'https://github.com/bobtfish/puppet-omnibus'
section 'Utilities'
name 'puppet-omnibus'
version ENV['PUPPET_BASE']
description 'Puppet Omnibus package'
revision ENV['PKG_ITERATION']
maintainer '<[email protected]>'
license 'Apache 2.0 License'
source '', :with => :noop
omnibus_package true
omnibus_dir "/opt/#{name}"
omnibus_recipes 'libaugeas', 'puppet', 'nginx'
conflicts(*%w{puppetmaster puppetmaster-passenger puppetmaster-common})
rel = `cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2`.chomp
case rel
when 'xenial', 'bionic'
depends 'libssl1.0.0'
else
depends 'libssl1.1'
end
def build
end
def install
create_post_install_hook
create_pre_uninstall_hook
# Set paths to package scripts
self.class.post_install builddir('post-install')
self.class.pre_uninstall builddir('pre-uninstall')
end
BINS="puppet facter hiera"
def create_post_install_hook
File.open(builddir('post-install'), 'w', 0755) do |f|
f.write <<-__POSTINST
#!/bin/sh
set -e
if [ "$1" = "configure" ]; then
# Create the "puppet" user
if ! getent passwd puppet > /dev/null; then
adduser --quiet --system --group --home /var/lib/puppet \
--no-create-home \
--gecos "Puppet configuration management daemon" \
puppet
fi
# Set correct permissions and ownership for puppet directories
if ! dpkg-statoverride --list /var/log/puppet >/dev/null 2>&1; then
dpkg-statoverride --update --add puppet puppet 0750 /var/log/puppet
fi
if ! dpkg-statoverride --list /var/lib/puppet >/dev/null 2>&1; then
dpkg-statoverride --update --add puppet puppet 0750 /var/lib/puppet
fi
# Create folders common to "puppet" and "puppetmaster", which need
# to be owned by the "puppet" user
install --owner puppet --group puppet --directory \
/var/lib/puppet/state
fi
BIN_PATH="#{destdir}/bin"
BINS="#{BINS}"
for BIN in $BINS; do
update-alternatives --install /usr/bin/$BIN $BIN $BIN_PATH/$BIN 100
done
exit 0
__POSTINST
end
end
def create_pre_uninstall_hook
File.open(builddir('pre-uninstall'), 'w', 0755) do |f|
f.write <<-__PRERM
#!/bin/sh
BIN_PATH="#{destdir}/bin"
BINS="#{BINS}"
if [ "$1" != "upgrade" ]; then
for BIN in $BINS; do
update-alternatives --remove $BIN $BIN_PATH/$BIN
done
fi
exit 0
__PRERM
end
end
end