forked from justinmajetich/AirBnB_clone
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path101-setup_web_static.pp
69 lines (65 loc) · 1.83 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
# sets up my web servers for the deployment of web_static
exec {'update':
provider => shell,
command => 'sudo apt -y update',
before => Exec['install nginx'],
}
exec {'install nginx':
provider => shell,
command => 'sudo apt -y install nginx',
require => Exec['update'],
}
file {'/data':
ensure => directory,
owner => 'ubuntu',
group => 'ubuntu',
}
file {'/data/web_static':
ensure => directory,
owner => 'ubuntu',
group => 'ubuntu',
require => File['/data'],
}
file {'/data/web_static/shared':
ensure => directory,
owner => 'ubuntu',
group => 'ubuntu',
require => File['/data/web_static'],
}
file {'/data/web_static/releases':
ensure => directory,
owner => 'ubuntu',
group => 'ubuntu',
require => File['/data/web_static'],
}
file {'/data/web_static/releases/test':
ensure => directory,
owner => 'ubuntu',
group => 'ubuntu',
require => File['/data/web_static/releases'],
}
file {'/data/web_static/releases/test/index.html':
ensure => file,
owner => 'ubuntu',
group => 'ubuntu',
content => 'Hello Web Static',
require => File['/data/web_static/releases/test'],
}
file {'/data/web_static/current':
ensure => link,
target => '/data/web_static/releases/test',
owner => 'ubuntu',
group => 'ubuntu',
}
$add = '\n\n\tlocation \/hbnb_static\/ {\n\t\talias \/data\/web_static\/current\/;\n\t}'
exec{'location hbnb_static':
provider => shell,
command => "sudo sed -i \"s/server_name _;/server_name _;${add}/\" /etc/nginx/sites-available/default",
require => Exec['install nginx'],
}
# restart nginx after config update
exec {'restart':
provider => shell,
command => 'sudo service nginx restart',
require => Exec['location hbnb_static'],
}