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
|
define ikiwiki::instance($base_url = $domain, $ensure = 'present', $description = false,
$adminuser = 'yourname', $adminemail = 'me@example.org', $instance = 'ikiwiki',
$account_creation_password = false, $add_plugins = false, $disable_plugins = false,
$protocol = 'https', $owner = $name, $group = $name, $home = "/home/$owner", $ssh_localhost_auth = false) {
$desc = $description ? {
false => $title,
default => $description,
}
case $ensure {
'present': {
file { "/etc/ikiwiki/$name.setup":
ensure => present,
content => template('ikiwiki/ikiwiki.setup.erb'),
owner => root,
group => $group,
mode => 640,
notify => Exec["ikiwiki_refresh_${name}_${instance}"],
}
exec { "ikiwiki_refresh_${name}_${instance}":
command => "/usr/local/sbin/ikiwiki-refresh $name $instance $owner $group",
user => root,
refreshonly => true,
}
exec { "ssh-keygen-ikiwiki-${name}_${instance}":
command => "ssh-keygen -t rsa -P '' -f ${home}/.ssh/id_rsa",
creates => "${home}/.ssh/id_rsa",
user => $owner,
group => $group,
require => File["${home}/.ssh"],
}
if !defined(File["${ikiwiki::sites_folder}/${name}/${instance}_src"]) {
file { "${ikiwiki::sites_folder}/${name}/${instance}_src":
ensure => directory,
owner => $owner,
group => $group,
recurse => true,
notify => Exec["ikiwiki_refresh_${name}_${instance}"],
require => File["${ikiwiki::sites_folder}/${name}"],
}
}
if !defined(File["${ikiwiki::sites_folder}/${name}/${instance}"]) {
file { "${ikiwiki::sites_folder}/${name}/${instance}":
ensure => directory,
owner => $owner,
group => $group,
recurse => true,
require => File["${ikiwiki::sites_folder}/${name}"],
}
}
if !defined(File["${home}/.ssh"]) {
file { "${home}/.ssh":
ensure => directory,
owner => $owner,
group => $group,
mode => 0700,
}
file { "${home}/.ssh/config":
ensure => present,
owner => $owner,
group => $group,
mode => 0600,
require => File["${home}/.ssh"],
}
file { "${home}/.ssh/known_hosts":
ensure => present,
owner => $owner,
group => $group,
mode => 0600,
require => File["${home}/.ssh"],
}
# The NoHostAuthenticationForLocalhost ssh option might be useful
# for automated deployment environments so your ikiwiki user doesn't
# get stuck with the fingerprint confirmation prompt when pushing
# content via ssh in the first time it runs.
line { 'NoHostAuthenticationForLocalhost-${owner}':
file => "${home}/.ssh/config",
line => "NoHostAuthenticationForLocalhost yes",
ensure => $ssh_localhost_auth ? {
'auto' => present,
'fingerprint' => absent,
default => absent,
},
}
# Alternativelly, you can choose to include the host's fingeprints
# directly into the known_hosts file.
if $::sshrsakey != '' {
line { 'known_hosts-localhost-rsa-${owner}':
file => "${home}/.ssh/known_hosts",
line => "localhost ssh-rsa ${::sshrsakey}",
ensure => $ssh_localhost_auth ? {
'fingerprint' => present,
'auto' => undef,
default => undef,
},
}
}
if $::sshdsakey != '' {
line { 'known_hosts-localhost-dsa-${owner}':
file => "${home}/.ssh/known_hosts",
line => "localhost ssh-dss ${::sshdsakey}",
ensure => $ssh_localhost_auth ? {
'fingerprint' => present,
'auto' => undef,
default => undef,
},
}
}
if $::sshecdsakey != '' {
line { 'known_hosts-localhost-ecdsa-${owner}':
file => "${home}/.ssh/known_hosts",
line => "localhost ecdsa-sha2-nistp256 ${::sshedsakey}",
ensure => $ssh_localhost_auth ? {
'fingerprint' => present,
'auto' => undef,
default => undef,
},
}
}
}
if !defined(File["${ikiwiki::sites_folder}/${name}"]) {
file { "${ikiwiki::sites_folder}/${name}":
ensure => directory,
owner => root,
group => root,
}
}
# See http://rtime.felk.cvut.cz/~sojka/blog/using-ikiwiki-with-gitolite/
file { "/var/git/repositories/${name}.git/hooks/post-update":
ensure => present,
owner => $owner,
group => $ikiwiki::git_implementation,
mode => 6550,
require => File["/etc/ikiwiki/$name.setup"],
}
file { "${ikiwiki::sites_folder}/${name}/${instance}/ikiwiki.cgi":
ensure => present,
owner => $owner,
group => $ikiwiki::www_user,
mode => 6550,
require => File["/etc/ikiwiki/$name.setup"],
}
}
'absent': {
file { "/etc/ikiwiki/$name.setup":
ensure => absent,
}
}
}
}
|