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
|
# File 'manifests/server.pp', line 26
class crypt::server (
$hostname = $crypt::params::hostname,
$admin_name,
$admin_email
) inherits crypt::params {
include apache
include apache::mod::wsgi
package {'git':
ensure => present,
}
package {'python-setuptools':
ensure => present,
require => Package['build-essential'],
}
package {'python-dev':
ensure => present,
require => Package['python-setuptools'],
}
package {'build-essential':
ensure => present,
require => Package['git'],
}
package {'python-pip':
ensure => present,
require => Package['python-dev'],
}
package {'python-virtualenv':
ensure => present,
require => Package['python-pip'],
}
vcsrepo { '/usr/local/crypt':
ensure => present,
require => Package['python-pip'],
provider => git,
source => 'https://github.com/grahamgilbert/Crypt-Server.git',
}
python::virtualenv { '/usr/local/crypt_env':
ensure => present,
version => 'system',
requirements => '/usr/local/crypt/setup/requirements.txt',
require => Vcsrepo['/usr/local/crypt'],
systempkgs => true,
}
file {'/usr/local/crypt/fvserver/settings.py':
ensure => present,
owner => www-data,
group => www-data,
content => template('crypt/settings.py.erb'),
require => Vcsrepo['/usr/local/crypt'],
}
file {'/usr/local/crypt/initial_data.json':
ensure => present,
owner => www-data,
group => www-data,
source => 'puppet:///modules/crypt/initial_data.json',
require => Vcsrepo['/usr/local/crypt'],
}
file {'/usr/local/crypt/crypt.wsgi':
ensure => present,
owner => www-data,
group => www-data,
source => 'puppet:///modules/crypt/crypt.wsgi',
require => Vcsrepo['/usr/local/crypt'],
}
file {'/usr/local/crypt/set_password.py':
ensure => present,
owner => www-data,
group => www-data,
content => template('crypt/set_password.py.erb'),
require => Vcsrepo['/usr/local/crypt'],
before => Exec['/usr/local/crypt_env/bin/python /usr/local/crypt/set_password.py'],
}
exec {'/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py syncdb --noinput':
require => [Python::Virtualenv['/usr/local/crypt_env'],File['/usr/local/crypt/initial_data.json']],
creates => '/usr/local/crypt/crypt.db',
path => '/usr/local/crypt_env/bin',
notify => Exec['/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py migrate'],
}
exec {'/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py migrate':
#require => Exec['/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py syncdb --noinput'],
path => '/usr/local/crypt_env/bin',
notify => Exec['/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py collectstatic --noinput'],
refreshonly => true,
}
exec {'/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py collectstatic --noinput':
require => Python::Virtualenv['/usr/local/crypt_env'],
path => '/usr/local/crypt_env/bin',
notify => Exec["/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py createsuperuser --noinput --email=${admin_email} --username=${admin_name}"],
refreshonly => true,
}
exec {"/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py createsuperuser --noinput --email=${admin_email} --username=${admin_name}":
#require => Exec['/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py syncdb --noinput'],
path => '/usr/local/crypt_env/bin',
notify => Exec['/usr/local/crypt_env/bin/python /usr/local/crypt/set_password.py'],
refreshonly => true,
}
exec {'/usr/local/crypt_env/bin/python /usr/local/crypt/set_password.py':
require => Exec['/usr/local/crypt_env/bin/python /usr/local/crypt/manage.py syncdb --noinput'],
path => '/usr/local/crypt_env/bin',
notify => [Service['httpd']],
refreshonly => true,
}
file {'/usr/local/crypt/crypt.db':
owner => www-data,
group => www-data,
require => Exec['/usr/local/crypt_env/bin/python /usr/local/crypt/set_password.py'],
}
apache::vhost { "${hostname}":
port => '80',
docroot => '/usr/local/crypt',
template => 'crypt/vhost.erb',
}
file {'/usr/local/crypt':
ensure => directory,
owner => www-data,
group => www-data,
recurse => true,
}
}
|