Saltstack Official Apache 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.

99 lines
2.9KB

  1. # frozen_string_literal: true
  2. # Overide by OS
  3. control 'apache configuration' do
  4. title 'should match desired lines'
  5. case platform[:family]
  6. when 'debian', 'suse'
  7. vhostdir = '/etc/apache2/sites-available'
  8. logrotatedir = '/etc/logrotate.d/apache2'
  9. moddir = '/etc/apache2/mods-enabled'
  10. sitesdir = '/etc/apache2/sites-enabled'
  11. when 'redhat', 'fedora'
  12. vhostdir = '/etc/httpd/vhosts.d'
  13. logrotatedir = '/etc/logrotate.d/httpd'
  14. moddir = '/etc/httpd/conf.modules.d'
  15. sitesdir = '/etc/httpd/sites-enabled'
  16. when 'gentoo'
  17. vhostdir = '/etc/apache2/vhosts.d'
  18. logrotatedir = '/etc/logrotate.d/apache2'
  19. moddir = '/etc/apache2/mods-enabled'
  20. sitesdir = '/etc/apache2/sites-enabled'
  21. # `linux` here is sufficient for `arch`
  22. when 'linux', 'arch'
  23. vhostdir = '/etc/httpd/conf/vhosts'
  24. logrotatedir = '/etc/logrotate.d/httpd'
  25. moddir = '/etc/httpd/conf.modules.d'
  26. sitesdir = '/etc/httpd/sites-enabled'
  27. when 'bsd'
  28. vhostdir = '/usr/local/etc/apache24/Includes'
  29. logrotatedir = '/usr/local/etc/logrotate.d/apache2'
  30. moddir = '/usr/local/etc/apache24/modules.d'
  31. # https://docs.freebsd.org/en/books/handbook/network-servers/#_virtual_hosting
  32. # All done under `/usr/local/etc/apache24/httpd.conf`
  33. sitesdir = '/usr/local/etc/apache24'
  34. end
  35. describe file(vhostdir) do
  36. it { should exist }
  37. it { should be_directory }
  38. its('type') { should eq :directory }
  39. end
  40. describe file(logrotatedir) do
  41. it { should exist }
  42. its('type') { should eq :file }
  43. end
  44. describe file(moddir) do
  45. it { should exist }
  46. it { should be_directory }
  47. its('type') { should eq :directory }
  48. end
  49. describe file(sitesdir) do
  50. it { should exist }
  51. it { should be_directory }
  52. its('type') { should eq :directory }
  53. end
  54. end
  55. control 'apache configuration (unique)' do
  56. title 'should be valid'
  57. config_file_group = 'root'
  58. case platform[:family]
  59. when 'debian'
  60. config_file = '/etc/apache2/apache2.conf'
  61. wwwdir = '/srv'
  62. when 'suse'
  63. config_file = '/etc/apache2/httpd.conf'
  64. wwwdir = '/srv/www'
  65. when 'redhat', 'fedora'
  66. config_file = '/etc/httpd/conf/httpd.conf'
  67. wwwdir = '/var/www'
  68. when 'gentoo'
  69. config_file = '/etc/apache2/httpd.conf'
  70. wwwdir = '/var/www'
  71. when 'linux', 'arch'
  72. config_file = '/etc/httpd/conf/httpd.conf'
  73. wwwdir = '/srv/http'
  74. when 'bsd'
  75. config_file = '/usr/local/etc/apache24/httpd.conf'
  76. config_file_group = 'wheel'
  77. wwwdir = '/usr/local/www/apache24/'
  78. end
  79. describe file(config_file) do
  80. it { should be_file }
  81. it { should be_grouped_into config_file_group }
  82. its('mode') { should cmp '0644' }
  83. its('content') do
  84. should include(
  85. 'This file is managed by Salt! Do not edit by hand!'
  86. )
  87. end
  88. end
  89. describe file(wwwdir) do
  90. it { should exist }
  91. it { should be_directory }
  92. its('type') { should eq :directory }
  93. end
  94. end