-
Notifications
You must be signed in to change notification settings - Fork 9
/
onetimesecret.pp
57 lines (49 loc) · 1.53 KB
/
onetimesecret.pp
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
user { 'ots':
ensure => present,
home => '/var/lib/onetime'
}
# Dependencies
package { [ 'redis-server', 'ntp', 'build-essential', 'libyaml-dev', 'libevent-dev', 'unzip',
'zlib1g', 'zlib1g-dev', 'openssl', 'libssl-dev', 'libxml2', 'wget' ]:
ensure => installed
}
# Ruby requirements
package { [ 'ruby1.9.1', 'ruby1.9.1-dev', 'bundler' ]:
ensure => installed
}
# Using foreman as process manager
package {'installforeman':
name => 'foreman',
ensure => 'installed',
provider => 'gem'
}
exec {'download-latest-onetime':
unless => '/usr/bin/test -f /etc/onetime/config',
command => '/usr/bin/wget -q -O /tmp/onetime.zip https://github.com/onetimesecret/onetimesecret/archive/master.zip',
creates => '/tmp/onetime.zip',
require => Package['wget'],
notify => Exec['unpack']
}
exec { 'unpack':
command => '/usr/bin/unzip /tmp/onetime.zip -d /var/lib/onetime/ && /bin/mv /var/lib/onetime/onetimesecret-master/* /var/lib/onetime/',
require => [File['/var/lib/onetime'], Package['unzip']],
notify => Exec['bundle'],
user => 'ots',
refreshonly => true
}
exec { 'bundle':
require => Package['bundler'],
cwd => '/var/lib/onetime',
command => '/usr/bin/bundle install --deployment --frozen --without=dev --gemfile /var/lib/onetime/Gemfile',
user => 'ots',
refreshonly => true
}
File {
require => User['ots'],
owner => 'ots',
mode => 0600,
}
file {
[ '/etc/onetime', '/var/log/onetime', '/var/run/onetime', '/var/lib/onetime']:
ensure => directory;
}