This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
init.pp
176 lines (164 loc) · 5.55 KB
/
init.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Class: osiam
#
# This class deploys the osiam war(s) into an application server and installs a
# database schema for postgresql. It can also install and configure the
# application server (tomcat 7) and database (postgres 9.2).
#
# Parameters:
# [*ensure*] - Wether to install or remove osiam. Valid arguments are absent or present.
# [*version*] - Version of osiam artifacts to deploy.
# [*dbuser*] - postgresql database username
# [*dbpassword*] - postgresql database user password
# [*dbname*] - postgresql database name
# [*dbhost*] - postgresql database hostname
# [*dbforceschema*] - if set to 'true' all database tables will be dropped and redeployed if there
# [*dbconnect*] - An array of IPs that can connect to the database using md5 auth method.
# [*installdb*] - true (default) to install and configure postgresql 9.2
# [*webappsdir*] - Tomcat7 webapps directory path.
# [*installas*] - true (default) to install and configure tomcat 7
# [*owner*] - Artifact owner on filesystem.
# [*group*] - Artifact group on filesystem.
# [*tomcatservice*] - Name of the tomcat service (for restarts)
# [*homedir*] - Directory for osiam non-war files.
# [*installjava*] - true (default) to install java 1.7
#
# Actions:
#
#
# Requires:
# maven installed
# puppet-maven module
# java 1.7
# unzip
#
# Sample Usage:
# class { 'osiam':
# ensure => present,
# version => '0.2-SNAPSHOT'
# webappsdir => '/var/lib/tomcat7/webapps'
# }
#
# Authors:
# Kevin Viola Schmitz <[email protected]>
#
class osiam (
$version,
$id = undef,
$ensure = present,
$homedir = '/etc/osiam',
$installdb = true,
$dbuser = 'ong',
$dbpassword = 'ong',
$dbname = 'ong',
$dbhost = $::fqdn,
$dbforceschema = false,
$dbconnect = $::ipaddress,
$installas = true,
$webappsdir = '/var/lib/tomcat7/webapps',
$owner = $osiam::params::tomcat_owner,
$group = $osiam::params::tomcat_group,
$forcessl = false,
$tomcatservice = 'tomcat7',
$installjava = true,
$installmaven = true,
$client_tag = 'osiam-client',
) {
class install {
if $osiam::installdb {
class { 'osiam::postgresql::install': }
class { 'osiam::postgresql::user': }
class { 'osiam::postgresql::database': }
}
if ( $osiam::installmaven ) or ( $osiam::installas ) {
class { 'osiam::jpackage': }
}
if $osiam::installmaven {
class { 'osiam::maven::install': }
}
if $osiam::installas {
class { 'osiam::tomcat::install': }
}
}
class config {
if $osiam::installas {
class { 'osiam::tomcat::config': }
}
}
class deploy {
file { $osiam::homedir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0744',
}
file { 'osiam.properties':
ensure => $osiam::ensure,
owner => 'root',
group => 'root',
mode => '0744',
path => "${osiam::homedir}/osiam.properties",
content => template('osiam/osiam.properties.erb'),
notify => Service[$osiam::tomcatservice],
require => File[$osiam::homedir],
}
war { 'osiam-auth-server':
ensure => $osiam::ensure,
version => $osiam::version,
id => $osiam::id,
path => $osiam::webappsdir,
owner => $osiam::owner,
group => $osiam::group,
require => File['osiam.properties'],
}
war { 'osiam-resource-server':
ensure => $osiam::ensure,
version => $osiam::version,
id => $osiam::id,
path => $osiam::webappsdir,
owner => $osiam::owner,
group => $osiam::group,
require => File['osiam.properties'],
}
# Note: only the resource server connects to the database
dbschema { 'osiam-resource-server':
ensure => $osiam::ensure,
artifactpath => $osiam::webappsdir,
osiampath => $osiam::homedir,
dbhost => $osiam::dbhost,
dbname => $osiam::dbname,
dbuser => $osiam::dbuser,
dbpassword => $osiam::dbpassword,
dbforceschema => $osiam::dbforceschema,
require => War['osiam-resource-server'],
}
$dbconnection = {
host => $osiam::dbhost,
name => $osiam::dbname,
user => $osiam::dbuser,
password => $osiam::dbpassword,
}
Osiamclient <<| tag == "${osiam::client_tag}" |>> {
dbconnection => $dbconnection,
require => Dbschema['osiam-resource-server'],
notify => Service[$osiam::tomcatservice],
}
}
if $ensure == 'present' {
$service_enable = true
$service_ensure = running
stage { 'install': before => Stage['main'], }
} else {
$service_enable = false
$service_ensure = stopped
stage { 'install': require => Stage['main'], }
}
class { 'install':
stage => 'install',
}
class { 'config':
stage => 'main',
}
class { 'deploy':
stage => 'main',
}
}