Skip to content

Commit 7271c9d

Browse files
committed
fix(passenger): various fixes
* correctly set dependencies in configuration * update RPM repo key * add tests for passenger installation as nginx module * update test matrix
1 parent b396b24 commit 7271c9d

File tree

14 files changed

+270
-11
lines changed

14 files changed

+270
-11
lines changed

.yamllint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ignore: |
1414
.cache/
1515
.git/
1616
node_modules/
17-
test/**/states/**/*.sls
17+
test/salt/**/*.sls
1818
.kitchen/
1919
2020
yaml-files:

nginx/map.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'Debian': {
1010
'package': 'nginx',
1111
'passenger_package': 'passenger',
12-
'passenger_config_file': '/etc/nginx/conf.d/passenger.conf',
12+
'passenger_config_file': '/etc/nginx/conf.d/mod-http-passenger.conf',
1313
'service': 'nginx',
1414
'webuser': 'www-data',
1515
'conf_file': '/etc/nginx/nginx.conf',

nginx/passenger.sls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ passenger_install:
2525
- pkg: nginx_install
2626
- require_in:
2727
- service: nginx_service
28+
- file: nginx_config
2829
2930
/etc/nginx/passenger.conf:
3031
file.absent:
@@ -46,6 +47,7 @@ passenger_config:
4647
- service: nginx_service
4748
- require_in:
4849
- service: nginx_service
50+
- file: nginx_config
4951
- require:
5052
- file: /etc/nginx/passenger.conf
5153
- pkg: passenger_install

nginx/pkg.sls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ nginx_phusionpassenger_yum_repo:
163163
- baseurl: 'https://oss-binaries.phusionpassenger.com/yum/passenger/el/$releasever/$basearch'
164164
- repo_gpgcheck: 1
165165
- gpgcheck: 0
166-
- gpgkey: 'https://packagecloud.io/gpg.key'
166+
- gpgkey: 'https://oss-binaries.phusionpassenger.com/yum/definitions/RPM-GPG-KEY.asc'
167167
- enabled: True
168168
- sslverify: 1
169169
- sslcacert: /etc/pki/tls/certs/ca-bundle.crt

nginx/snippets.sls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ nginx_snippet_{{ snippet }}:
2828
- context:
2929
config: {{ config|json() }}
3030
nginx: {{ _nginx|json() }}
31+
- require:
32+
- file: nginx_snippets_dir
33+
- require_in:
34+
- file: nginx_config
35+
- service: nginx_service
3136
{% endfor %}

test/integration/default/controls/config.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# frozen_string_literal: true
2+
13
# Set defaults, use debian as base
24

35
server_available = '/etc/nginx/sites-available'
4-
server_enabled = '/etc/nginx/sites-enabled'
6+
server_enabled = '/etc/nginx/sites-enabled'
57

68
# Override by platform family
79
case platform[:family]
@@ -22,9 +24,13 @@
2224
it { should be_owned_by 'root' }
2325
it { should be_grouped_into 'root' }
2426
its('mode') { should cmp '0644' }
25-
its('content') { should include %Q[ log_format main '$remote_addr - $remote_user [$time_local] $status '
27+
its('content') do
28+
# rubocop:disable Metrics/LineLength
29+
should include %( log_format main '$remote_addr - $remote_user [$time_local] $status '
2630
'"$request" $body_bytes_sent "$http_referer" '
27-
'"$http_user_agent" "$http_x_forwarded_for"';] }
31+
'"$http_user_agent" "$http_x_forwarded_for"';)
32+
# rubocop:enable Metrics/LineLength
33+
end
2834
end
2935

3036
# snippets configuration
@@ -40,12 +46,11 @@
4046

4147
# sites configuration
4248
[server_available, server_enabled].each do |dir|
43-
44-
describe file ("#{dir}/default") do
45-
it { should_not exist }
49+
describe file "#{dir}/default" do
50+
it { should_not exist }
4651
end
4752

48-
describe file ("#{dir}/mysite") do
53+
describe file "#{dir}/mysite" do
4954
it { should be_file }
5055
it { should be_owned_by 'root' }
5156
it { should be_grouped_into 'root' }
@@ -57,6 +62,5 @@
5762
its('content') { should include 'try_files $uri $uri/ =404;' }
5863
its('content') { should include 'include snippets/letsencrypt.conf;' }
5964
end
60-
6165
end
6266
end

test/integration/default/controls/install.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
control 'Nginx package' do
24
title 'should be installed'
35

test/integration/default/controls/service.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
control 'Nginx service' do
24
title 'should be running and enabled'
35

test/integration/passenger/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# InSpec Profile: `passenger`
2+
3+
This shows the implementation of the `passenger` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
4+
5+
## Verify a profile
6+
7+
InSpec ships with built-in features to verify a profile structure.
8+
9+
```bash
10+
$ inspec check passenger
11+
Summary
12+
-------
13+
Location: passenger
14+
Profile: profile
15+
Controls: 4
16+
Timestamp: 2019-06-24T23:09:01+00:00
17+
Valid: true
18+
19+
Errors
20+
------
21+
22+
Warnings
23+
--------
24+
```
25+
26+
## Execute a profile
27+
28+
To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.
29+
30+
```bash
31+
$ inspec exec passenger
32+
..
33+
34+
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
35+
8 examples, 0 failures
36+
```
37+
38+
## Execute a specific control from a profile
39+
40+
To run one control from the profile use `inspec exec /path/to/profile --controls name`.
41+
42+
```bash
43+
$ inspec exec passenger --controls package
44+
.
45+
46+
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
47+
1 examples, 0 failures
48+
```
49+
50+
See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# frozen_string_literal: true
2+
3+
# Set defaults, use debian as base
4+
5+
# Override by OS Family
6+
case platform[:family]
7+
when 'redhat', 'centos', 'fedora'
8+
server_available = '/etc/nginx/conf.d'
9+
server_enabled = '/etc/nginx/conf.d'
10+
passenger_mod = '/usr/lib64/nginx/modules/ngx_http_passenger_module.so'
11+
passenger_root = '/usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini'
12+
passenger_config_file = '/etc/nginx/conf.d/passenger.conf'
13+
should_not_exist_file = '/etc/nginx/conf.d/mod-http-passenger.conf'
14+
when 'debian', 'ubuntu'
15+
server_available = '/etc/nginx/sites-available'
16+
server_enabled = '/etc/nginx/sites-enabled'
17+
passenger_mod = '/usr/lib/nginx/modules/ngx_http_passenger_module.so'
18+
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
19+
passenger_config_file = '/etc/nginx/conf.d/mod-http-passenger.conf'
20+
should_not_exist_file = '/etc/nginx/conf.d/passenger.conf'
21+
end
22+
23+
control 'Passenger configuration' do
24+
title 'should match desired lines'
25+
26+
# main configuration
27+
describe file('/etc/nginx/nginx.conf') do
28+
its('content') { should include "load_module #{passenger_mod}" }
29+
end
30+
31+
describe file(passenger_config_file) do
32+
it { should be_file }
33+
it { should be_owned_by 'root' }
34+
it { should be_grouped_into 'root' }
35+
its('mode') { should cmp '0644' }
36+
its('content') { should include "passenger_root #{passenger_root};" }
37+
its('content') { should include 'passenger_ruby /usr/bin/ruby;' }
38+
end
39+
40+
describe file(should_not_exist_file) do
41+
it { should_not exist }
42+
end
43+
44+
# sites configuration
45+
[server_available, server_enabled].each do |dir|
46+
describe file "#{dir}/default" do
47+
it { should_not exist }
48+
end
49+
50+
describe file "#{dir}/mysite" do
51+
it { should be_file }
52+
it { should be_owned_by 'root' }
53+
it { should be_grouped_into 'root' }
54+
its('mode') { should cmp '0644' }
55+
its('content') { should include 'passenger_enabled on;' }
56+
end
57+
end
58+
end

0 commit comments

Comments
 (0)