forked from justinmajetich/AirBnB_clone
-
Notifications
You must be signed in to change notification settings - Fork 10
/
101-setup_web_static.pp
88 lines (72 loc) · 1.67 KB
/
101-setup_web_static.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
# Configures a web server for deployment of web_static.
# Nginx configuration file
$nginx_conf = "server {
listen 80 default_server;
listen [::]:80 default_server;
add_header X-Served-By ${hostname};
root /var/www/html;
index index.html index.htm;
location /hbnb_static {
alias /data/web_static/current;
index index.html index.htm;
}
location /redirect_me {
return 301 https://th3-gr00t.tk;
}
error_page 404 /404.html;
location /404 {
root /var/www/html;
internal;
}
}"
package { 'nginx':
ensure => 'present',
provider => 'apt'
} ->
file { '/data':
ensure => 'directory'
} ->
file { '/data/web_static':
ensure => 'directory'
} ->
file { '/data/web_static/releases':
ensure => 'directory'
} ->
file { '/data/web_static/releases/test':
ensure => 'directory'
} ->
file { '/data/web_static/shared':
ensure => 'directory'
} ->
file { '/data/web_static/releases/test/index.html':
ensure => 'present',
content => "Holberton School Puppet\n"
} ->
file { '/data/web_static/current':
ensure => 'link',
target => '/data/web_static/releases/test'
} ->
exec { 'chown -R ubuntu:ubuntu /data/':
path => '/usr/bin/:/usr/local/bin/:/bin/'
}
file { '/var/www':
ensure => 'directory'
} ->
file { '/var/www/html':
ensure => 'directory'
} ->
file { '/var/www/html/index.html':
ensure => 'present',
content => "Holberton School Nginx\n"
} ->
file { '/var/www/html/404.html':
ensure => 'present',
content => "Ceci n'est pas une page\n"
} ->
file { '/etc/nginx/sites-available/default':
ensure => 'present',
content => $nginx_conf
} ->
exec { 'nginx restart':
path => '/etc/init.d/'
}