forked from joshbeard/puppet-bamboo
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.pp
106 lines (94 loc) · 3.06 KB
/
install.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
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
# Private class to manage Bamboo installation
#
class bamboo::install {
$file = "atlassian-bamboo-${bamboo::version}.${bamboo::extension}"
if $bamboo::manage_user {
user { $bamboo::user:
ensure => 'present',
comment => 'Bamboo service account',
shell => $bamboo::shell,
home => $bamboo::homedir,
password => $bamboo::password,
password_min_age => '0',
password_max_age => '99999',
managehome => true,
uid => $bamboo::uid,
gid => $bamboo::gid,
}
}
if $bamboo::manage_group {
group { $bamboo::group:
ensure => 'present',
gid => $bamboo::gid,
}
}
if $bamboo::manage_installdir {
file { $bamboo::installdir:
ensure => 'directory',
owner => $bamboo::user,
group => $bamboo::group,
}
}
if $bamboo::manage_appdir {
file { $bamboo::real_appdir:
ensure => 'directory',
owner => $bamboo::user,
group => $bamboo::group,
before => Archive[$file],
}
}
file { $bamboo::homedir:
ensure => 'directory',
owner => $bamboo::user,
group => $bamboo::group,
mode => '0750',
}
# If a value for `checksum` is specified, set `checksum_verify` on the `archive` module implicitly.
if $bamboo::checksum == undef {
$checksum_verify = false
} else {
$checksum_verify = true
}
archive { $file:
source => "${bamboo::download_url}/${file}",
path => "/tmp/${file}",
extract => true,
extract_command => 'tar xzf %s --strip-components=1',
extract_path => $bamboo::real_appdir,
cleanup => true,
proxy_server => $bamboo::proxy_server,
proxy_type => $bamboo::proxy_type,
allow_insecure => true,
creates => "${bamboo::real_appdir}/conf",
user => $bamboo::user,
group => $bamboo::group,
checksum_verify => $checksum_verify,
checksum_type => $bamboo::checksum_type,
checksum => $bamboo::checksum,
}
#
# If the 'bamboo_version' fact is defined (as provided by this module),
# compare it to the specified version. If it doesn't match, stop the
# bamboo service prior to upgrading but after downloading the new version
#
if defined('$::bamboo_version') {
if versioncmp($bamboo::version, $facts['bamboo_version']) > 0 {
notify { "Updating Bamboo from version ${facts['bamboo_version']} to ${bamboo::version}": }
exec { $bamboo::stop_command:
path => $facts['path'],
require => Archive[$file],
}
}
}
file { "${bamboo::homedir}/logs":
ensure => 'directory',
owner => $bamboo::user,
group => $bamboo::group,
}
exec { "chown_${bamboo::real_appdir}":
command => "chown -R ${bamboo::user}:${bamboo::group} ${bamboo::real_appdir}",
unless => "find ${bamboo::real_appdir} ! -type l \\( ! -user ${bamboo::user} \\) \
-o \\( ! -group ${bamboo::group} \\) | wc -l | awk '{print \$1}' | grep -qE '^0'",
path => '/bin:/usr/bin',
}
}