This repository has been archived by the owner on Nov 18, 2020. It is now read-only.
forked from croomes/puppet-bamboo
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstall.pp
113 lines (102 loc) · 3.11 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
107
108
109
110
111
112
113
class bamboo::install (
$user = $bamboo::user,
$group = $bamboo::group,
$uid = $bamboo::uid,
$gid = $bamboo::gid,
$password = $bamboo::password,
$homedir = $bamboo::homedir,
$shell = $bamboo::shell,
$download_url = $bamboo::download_url,
$installdir = $bamboo::installdir,
$version = $bamboo::version,
$appdir = $bamboo::real_appdir,
$extension = $bamboo::extension,
$manage_user = $bamboo::manage_user,
$manage_group = $bamboo::manage_group,
$manage_installdir = $bamboo::manage_installdir,
$manage_appdir = $bamboo::manage_appdir,
$stop_command = $bamboo::stop_command,
$proxy_server = $bamboo::proxy_server,
$proxy_type = $bamboo::proxy_type,
) {
$file = "atlassian-bamboo-${version}.${extension}"
if $manage_user {
user { $user:
ensure => 'present',
comment => 'Bamboo service account',
shell => $shell,
home => $homedir,
password => $password,
password_min_age => '0',
password_max_age => '99999',
managehome => true,
uid => $uid,
gid => $gid,
}
}
if $manage_group {
group { $group:
ensure => 'present',
gid => $gid,
}
}
if $manage_installdir {
file { $installdir:
ensure => 'directory',
owner => $user,
group => $group,
}
}
if $manage_appdir {
file { $appdir:
ensure => 'directory',
owner => $user,
group => $group,
before => Archive[$file],
}
}
file { $homedir:
ensure => 'directory',
owner => $user,
group => $group,
mode => '0750',
}
archive { $file:
source => "${download_url}/${file}",
path => "/tmp/${file}",
extract => true,
extract_command => 'tar xzf %s --strip-components=1',
extract_path => $appdir,
cleanup => true,
proxy_server => $proxy_server,
proxy_type => $proxy_type,
allow_insecure => true,
creates => "${appdir}/conf",
user => $user,
group => $group,
}
#
# 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, $::bamboo_version) > 0 {
notify { "Updating Bamboo from version ${::bamboo_version} to ${::bamboo::version}": }
exec { $stop_command:
path => $::path,
require => Archive[$file],
}
}
}
file { "${homedir}/logs":
ensure => 'directory',
owner => $user,
group => $group,
}
exec { "chown_${appdir}":
command => "chown -R ${user}:${group} ${appdir}",
unless => "find ${appdir} ! -type l \\( ! -user ${user} \\) -o \\( ! -group ${group} \\) | wc -l | awk '{print \$1}' | grep -qE '^0'",
path => '/bin:/usr/bin',
}
}