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
|
# File 'manifests/configapp.pp', line 1
class twlight::configapp inherits twlight {
# reload systemd
exec { 'daemon_reload':
command => '/bin/systemctl daemon-reload',
subscribe => [ File["${root_dir}/TWLight/settings/${environment}_vars.py"], File['/etc/rc3.d/S05gunicorn'] ],
notify => Exec['nginx_reload'],
}
# Install cssjanus in twlight users homedir
exec { 'npm_install_cssjanus':
command => '/usr/bin/npm install cssjanus',
cwd => "/home/${unixname}",
user => "${unixname}",
}
file { '/etc/nginx/sites-available/twlight':
ensure => file,
content => template('twlight/nginx.conf.twlight.erb'),
owner => '33',
group => '33',
mode => '0644',
}
file { '/etc/nginx/sites-enabled/twlight':
ensure => 'link',
target => '/etc/nginx/sites-available/twlight',
force => true,
}
# TWLight app log
file { "${root_dir}/TWLight/logs/twlight.log":
ensure => file,
owner => $unixname,
group => $unixname,
mode => '0644',
}
# Gunicorn server log
file { "${root_dir}/TWLight/logs/gunicorn.log":
ensure => file,
owner => $unixname,
group => $unixname,
mode => '0644',
}
# TWLight update log
file { "${root_dir}/TWLight/logs/update.log":
ensure => file,
owner => $unixname,
group => $unixname,
mode => '0644',
}
# TWLight test log
file { "${root_dir}/TWLight/logs/test.log":
ensure => file,
owner => $unixname,
group => $unixname,
mode => '0644',
}
# Set perms for TWLight tree
file { "${root_dir}":
ensure => directory,
recurse => true,
owner => $unixname,
group => $unixname,
}
# We always write out local vars so that we can run tests.
if $environment != 'local' {
file { "${root_dir}/TWLight/settings/local_vars.py":
ensure => file,
content => template('twlight/local_vars.py.erb'),
owner => $unixname,
group => $unixname,
mode => '0400',
}
}
file { "${root_dir}/TWLight/settings/${environment}_vars.py":
ensure => file,
content => template("twlight/${environment}_vars.py.erb"),
owner => $unixname,
group => $unixname,
mode => '0400',
}
# Global environment variables.
file { '/etc/environment':
mode => '0644',
owner => 'root',
group => 'root',
content => template('twlight/environment.erb'),
}
# gunicorn config
file {'/etc/init.d/gunicorn':
mode => '0755',
owner => 'root',
group => 'root',
content => template('twlight/gunicorn.erb'),
}
# gunicorn start on boot
file { '/etc/rc3.d/S05gunicorn':
ensure => 'link',
target => '/etc/init.d/gunicorn',
force => true,
}
# These cron tasks don't make too much sense in local environments
if $environment != 'local' {
# weekly cron task
file { '/etc/cron.weekly/twlight':
ensure => 'link',
target => "${root_dir}/bin/twlight_weekly.sh",
force => true,
}
# cron deploy task
file { '/etc/cron.d/twlight':
mode => '0644',
owner => '0',
group => '0',
source => 'puppet:///modules/twlight/deploy.cron',
}
# cron backup task
file {'/etc/cron.daily/twlight':
mode => '0644',
owner => '33',
group => '33',
source => 'puppet:///modules/twlight/backup.cron',
}
}
}
|