-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.pp
94 lines (84 loc) · 2.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
# == Class: appsvn
#
# Full description of class appsvn here.
#
# === Parameters
#
# Document parameters here.
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
# e.g. "Specify one or more upstream ntp servers as an array."
#
# === Variables
#
# Here you should define a list of variables that this module would require.
#
# [*sample_variable*]
# Explanation of how this variable affects the funtion of this class and if it
# has a default. e.g. "The parameter enc_ntp_servers must be set by the
# External Node Classifier as a comma separated list of hostnames." (Note,
# global variables should not be used in preference to class parameters as of
# Puppet 2.6.)
#
# === Examples
#
# class { appsvn:
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ]
# }
#
# === Authors
#
# Author Name <author@domain.com>
#
# === Copyright
#
# Copyright 2013 Your name here, unless otherwise noted.
#
class appsvn (
$public_key,
$private_key,
$key_base_name = 'appsvn',
$protocol = 'http',
$user = 'svnuser',
$server = "svn.${::domain}",
$base_path = "/x01/svn/hjapps",
$branch = 'trunk',
) {
# validate $server
$server_is_ip_address = is_ip_address($server)
$server_is_domain_name = is_domain_name($server)
if ($server_is_ip_address == false) and ($server_is_domain_name == false) {
fail("server <${server}> must be a valid IP address or host name")
}
# validate protocol
validate_re($protocol, '^(http|https|svn|svn\+ssh)$', "appsvn::protocol <${protocol}> does not match regex")
# include ssh class if the protocol is svn+ssh. This class will ensure ssh is
# setup and allows for the specification of the contents of root's
# ~/.ssh/config
if $protocol == 'svn+ssh' {
include ssh
}
# validate $user
validate_re($user, '^[a-z][-a-z0-9]*$', "appsvn::user <${user}> does not match regex")
# validate $public_key
validate_re($public_key, '^ssh-(rsa|dsa).*', "appsvn::public_key <${public_key}> does not match regex")
# validate $branch
validate_re($branch, '^([^\/\0]+(\/)?)+$', "appsvn::branch <${branch}> does not match regex")
file { 'appsvn_public_key':
ensure => file,
content => $public_key,
path => "${::root_home}/.ssh/${key_base_name}.pub",
owner => 'root',
group => 'root',
mode => '0600',
}
file { 'appsvn_private_key':
ensure => file,
content => $private_key,
path => "${::root_home}/.ssh/${key_base_name}",
owner => 'root',
group => 'root',
mode => '0600',
}
}