|
2 | 2 |
|
3 | 3 | # Set defaults, use debian as base
|
4 | 4 |
|
5 |
| -server_available = '/etc/nginx/sites-available' |
6 |
| -server_enabled = '/etc/nginx/sites-enabled' |
7 |
| - |
8 | 5 | # Override by platform family
|
9 |
| -case platform[:family] |
10 |
| -when 'redhat', 'fedora' |
11 |
| - server_available = '/etc/nginx/conf.d' |
12 |
| - server_enabled = '/etc/nginx/conf.d' |
13 |
| -when 'suse' |
14 |
| - server_available = '/etc/nginx/vhosts.d' |
15 |
| - server_enabled = '/etc/nginx/vhosts.d' |
16 |
| -end |
| 6 | +server_available, server_enabled = |
| 7 | + case platform[:family] |
| 8 | + when 'redhat', 'fedora' |
| 9 | + %w[/etc/nginx/conf.d /etc/nginx/conf.d] |
| 10 | + when 'suse' |
| 11 | + %w[/etc/nginx/vhosts.d /etc/nginx/vhosts.d] |
| 12 | + when 'bsd' |
| 13 | + %w[/usr/local/etc/nginx/sites-available /usr/local/etc/nginx/sites-enabled] |
| 14 | + else |
| 15 | + %w[/etc/nginx/sites-available /etc/nginx/sites-enabled] |
| 16 | + end |
| 17 | + |
| 18 | +nginx_conf, snippets_letsencrypt_conf, file_owner, file_group = |
| 19 | + case platform[:family] |
| 20 | + when 'bsd' |
| 21 | + %w[/usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/snippets/letsencrypt.conf |
| 22 | + root wheel] |
| 23 | + else |
| 24 | + %w[/etc/nginx/nginx.conf /etc/nginx/snippets/letsencrypt.conf root root] |
| 25 | + end |
17 | 26 |
|
18 | 27 | control 'Nginx configuration' do
|
19 | 28 | title 'should match desired lines'
|
20 | 29 |
|
21 | 30 | # main configuration
|
22 |
| - describe file('/etc/nginx/nginx.conf') do |
| 31 | + describe file(nginx_conf) do |
23 | 32 | it { should be_file }
|
24 |
| - it { should be_owned_by 'root' } |
25 |
| - it { should be_grouped_into 'root' } |
| 33 | + it { should be_owned_by file_owner } |
| 34 | + it { should be_grouped_into file_group } |
26 | 35 | its('mode') { should cmp '0644' }
|
27 | 36 | its('content') do
|
28 | 37 | # rubocop:disable Metrics/LineLength
|
|
34 | 43 | end
|
35 | 44 |
|
36 | 45 | # snippets configuration
|
37 |
| - describe file('/etc/nginx/snippets/letsencrypt.conf') do |
| 46 | + describe file(snippets_letsencrypt_conf) do |
38 | 47 | it { should be_file }
|
39 |
| - it { should be_owned_by 'root' } |
40 |
| - it { should be_grouped_into 'root' } |
| 48 | + it { should be_owned_by file_owner } |
| 49 | + it { should be_grouped_into file_group } |
41 | 50 | its('mode') { should cmp '0644' }
|
42 | 51 | its('content') { should include 'location ^~ /.well-known/acme-challenge/ {' }
|
43 | 52 | its('content') { should include 'proxy_pass http://localhost:9999;' }
|
|
52 | 61 |
|
53 | 62 | describe file "#{dir}/mysite" do
|
54 | 63 | it { should be_file }
|
55 |
| - it { should be_owned_by 'root' } |
56 |
| - it { should be_grouped_into 'root' } |
| 64 | + it { should be_owned_by file_owner } |
| 65 | + it { should be_grouped_into file_group } |
57 | 66 | its('mode') { should cmp '0644' }
|
58 | 67 | its('content') { should include 'server_name localhost;' }
|
59 | 68 | its('content') { should include 'listen 80 default_server;' }
|
|
0 commit comments