Saltstack Official Nginx Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1KB

  1. # Set defaults, use debian as base
  2. server_available = '/etc/nginx/sites-available'
  3. server_enabled = '/etc/nginx/sites-enabled'
  4. # Override by OS
  5. case os[:name]
  6. when 'redhat', 'centos', 'fedora'
  7. server_available = '/etc/nginx/conf.d'
  8. server_enabled = '/etc/nginx/conf.d'
  9. when 'opensuse'
  10. server_available = '/etc/nginx/vhosts.d'
  11. server_enabled = '/etc/nginx/vhosts.d'
  12. end
  13. control 'Nginx configuration' do
  14. title 'should match desired lines'
  15. # main configuration
  16. describe file('/etc/nginx/nginx.conf') do
  17. it { should be_file }
  18. it { should be_owned_by 'root' }
  19. it { should be_grouped_into 'root' }
  20. its('mode') { should cmp '0644' }
  21. its('content') { should include %Q[ log_format main '$remote_addr - $remote_user [$time_local] $status '
  22. '"$request" $body_bytes_sent "$http_referer" '
  23. '"$http_user_agent" "$http_x_forwarded_for"';] }
  24. end
  25. # snippets configuration
  26. describe file('/etc/nginx/snippets/letsencrypt.conf') do
  27. it { should be_file }
  28. it { should be_owned_by 'root' }
  29. it { should be_grouped_into 'root' }
  30. its('mode') { should cmp '0644' }
  31. its('content') { should include 'location ^~ /.well-known/acme-challenge/ {' }
  32. its('content') { should include 'proxy_pass http://localhost:9999;' }
  33. its('content') { should include '{' }
  34. end
  35. # sites configuration
  36. [server_available, server_enabled].each do |dir|
  37. describe file ("#{dir}/default") do
  38. it { should_not exist }
  39. end
  40. describe file ("#{dir}/mysite") do
  41. it { should be_file }
  42. it { should be_owned_by 'root' }
  43. it { should be_grouped_into 'root' }
  44. its('mode') { should cmp '0644' }
  45. its('content') { should include 'server_name localhost;' }
  46. its('content') { should include 'listen 80 default_server;' }
  47. its('content') { should include 'index index.html index.htm;' }
  48. its('content') { should include 'location ~ .htm {' }
  49. its('content') { should include 'try_files $uri $uri/ =404;' }
  50. its('content') { should include 'include snippets/letsencrypt.conf;' }
  51. end
  52. end
  53. end