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.

121 lines
3.5KB

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