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.

111 lines
3.0KB

  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 = ?
  36. # moddir = '?'
  37. # sitesdir = '?'
  38. end
  39. describe command(apachectl) do
  40. its('stdout') { should eq '' }
  41. its('stderr') { should include 'Syntax OK' }
  42. its('exit_status') { should eq 0 }
  43. end
  44. describe file(vhostdir) do
  45. it { should exist }
  46. it { should be_directory }
  47. its('type') { should eq :directory }
  48. end
  49. describe file(logrotatedir) do
  50. it { should exist }
  51. its('type') { should eq :file }
  52. end
  53. describe file(logdir) do
  54. it { should exist }
  55. it { should be_directory }
  56. its('type') { should eq :directory }
  57. end
  58. describe file(moddir) do
  59. it { should exist }
  60. it { should be_directory }
  61. its('type') { should eq :directory }
  62. end
  63. describe file(sitesdir) do
  64. it { should exist }
  65. it { should be_directory }
  66. its('type') { should eq :directory }
  67. end
  68. end
  69. control 'apache configuration (unique)' do
  70. title 'should match desired lines'
  71. case platform[:family]
  72. when 'debian'
  73. config_file = '/etc/apache2/apache2.conf'
  74. wwwdir = '/srv'
  75. when 'suse'
  76. config_file = '/etc/apache2/httpd.conf'
  77. wwwdir = '/srv/www'
  78. when 'redhat', 'fedora'
  79. config_file = '/etc/httpd/conf/httpd.conf'
  80. wwwdir = '/var/www'
  81. when 'gentoo'
  82. config_file = '/etc/apache2/httpd.conf'
  83. wwwdir = '/var/www'
  84. when 'linux', 'arch'
  85. config_file = '/etc/httpd/conf/httpd.conf'
  86. wwwdir = '/srv/http'
  87. when 'bsd'
  88. config_file = '/usr/local/etc/apache24/httpd.conf'
  89. wwwdir = '/usr/local/www/apache24/'
  90. end
  91. describe file(config_file) do
  92. it { should be_file }
  93. it { should be_grouped_into 'root' }
  94. its('mode') { should cmp '0644' }
  95. its('content') do
  96. should include(
  97. 'This file is managed by Salt! Do not edit by hand!'
  98. )
  99. end
  100. end
  101. describe file(wwwdir) do
  102. it { should exist }
  103. it { should be_directory }
  104. its('type') { should eq :directory }
  105. end
  106. end