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.

60 lines
1.8KB

  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. end
  22. # snippets configuration
  23. describe file('/etc/nginx/snippets/letsencrypt.conf') do
  24. it { should be_file }
  25. it { should be_owned_by 'root' }
  26. it { should be_grouped_into 'root' }
  27. its('mode') { should cmp '0644' }
  28. its('content') { should include 'location ^~ /.well-known/acme-challenge/ {' }
  29. its('content') { should include 'proxy_pass http://localhost:9999;' }
  30. its('content') { should include '{' }
  31. end
  32. # sites configuration
  33. [server_available, server_enabled].each do |dir|
  34. describe file ("#{dir}/default") do
  35. it { should_not exist }
  36. end
  37. describe file ("#{dir}/mysite") do
  38. it { should be_file }
  39. it { should be_owned_by 'root' }
  40. it { should be_grouped_into 'root' }
  41. its('mode') { should cmp '0644' }
  42. its('content') { should include 'server_name localhost;' }
  43. its('content') { should include 'listen 80 default_server;' }
  44. its('content') { should include 'index index.html index.htm;' }
  45. its('content') { should include 'location ~ .htm {' }
  46. its('content') { should include 'try_files $uri $uri/ =404;' }
  47. its('content') { should include 'include snippets/letsencrypt.conf;' }
  48. end
  49. end
  50. end