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.

115 lines
3.3KB

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