-
Notifications
You must be signed in to change notification settings - Fork 0
/
101-setup_web_static.pp
91 lines (72 loc) · 1.85 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
89
90
91
# Configures a web server for deployment of web_static using Puppet
# This is a Puppet manifest file that configures a web server for deployment of web_static. It installs Nginx, creates the necessary directories, and sets up the server block to serve the content.
$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 http://cuberule.com/;
}
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/'
}