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

107 lines
4.3KB

  1. # frozen_string_literal: true
  2. title 'Test logrotate jobs configuration'
  3. describe file('/etc/logrotate.d/error') do
  4. it { should be_file }
  5. it { should be_owned_by 'root' }
  6. it { should be_grouped_into 'root' }
  7. its('mode') { should cmp '0644' }
  8. its('content') { should include '/tmp/var/log/mysql/error' }
  9. its('content') { should include 'weekly' }
  10. its('content') { should include 'missingok' }
  11. its('content') { should include 'rotate 52' }
  12. its('content') { should include 'compress' }
  13. its('content') { should include 'delaycompress' }
  14. its('content') { should include 'notifempty' }
  15. its('content') { should include 'create 640 root adm' }
  16. its('content') { should include 'sharedscripts' }
  17. end
  18. describe file('/etc/logrotate.d/mysql') do
  19. it { should be_file }
  20. it { should be_owned_by 'root' }
  21. it { should be_grouped_into 'root' }
  22. its('mode') { should cmp '0644' }
  23. its('content') { should include '/tmp/var/log/mysql/*.log' }
  24. its('content') { should include 'weekly' }
  25. its('content') { should include 'missingok' }
  26. its('content') { should include 'rotate 52' }
  27. its('content') { should include 'compress' }
  28. its('content') { should include 'delaycompress' }
  29. its('content') { should include 'notifempty' }
  30. its('content') { should include 'create 640 root adm' }
  31. its('content') { should include 'sharedscripts' }
  32. end
  33. describe file('/etc/logrotate.d/syslog') do
  34. it { should be_file }
  35. it { should be_owned_by 'root' }
  36. it { should be_grouped_into 'root' }
  37. its('mode') { should cmp '0644' }
  38. its('content') { should include '/var/log/cron' }
  39. its('content') { should include '/var/log/maillog' }
  40. its('content') { should include '/var/log/messages' }
  41. its('content') { should include '/var/log/secure' }
  42. its('content') { should include '/var/log/spooler' }
  43. its('content') { should include '/var/log/slapd.log' }
  44. its('content') { should include 'sharedscripts' }
  45. its('content') { should include 'postrotate' }
  46. its('content') { should include 'sharedscripts' }
  47. end
  48. describe file('/etc/logrotate.d/nginx') do
  49. it { should be_file }
  50. it { should be_owned_by 'root' }
  51. it { should be_grouped_into 'root' }
  52. its('mode') { should cmp '0644' }
  53. its('content') { should include '/var/log/nginx/*.log' }
  54. its('content') { should include 'weekly' }
  55. its('content') { should include 'missingok' }
  56. its('content') { should include 'compress' }
  57. its('content') { should include 'delaycompress' }
  58. its('content') { should include 'prerotate' }
  59. its('content') do
  60. should include 'if [ -d /etc/logrotate.d/httpd-prerotate ]; then \\'
  61. end
  62. its('content') { should include ' run-parts /etc/logrotate.d/httpd-prerotate; \\' }
  63. its('content') { should include ' fi \\' }
  64. its('content') { should include 'postrotate' }
  65. its('content') { should include ' invoke-rc.d nginx rotate >/dev/null 2>&1' }
  66. end
  67. describe file('/etc/logrotate.hourly.d/nginx_high_traf') do
  68. it { should be_file }
  69. it { should be_owned_by 'root' }
  70. it { should be_grouped_into 'root' }
  71. its('mode') { should cmp '0644' }
  72. its('content') { should include '/var/log/nginx_high_traf/*.log' }
  73. its('content') { should include 'hourly' }
  74. its('content') { should include 'missingok' }
  75. its('content') { should include 'rotate 720' }
  76. its('content') { should include 'compress' }
  77. its('content') { should include 'notifempty' }
  78. its('content') { should include 'dateext' }
  79. its('content') { should include 'dateformat .%Y-%m-%d-%H00' }
  80. its('content') { should include 'olddir /var/log/nginx_high_traf/archive' }
  81. its('content') { should include 'sharedscripts' }
  82. its('content') { should include 'postrotate' }
  83. its('content') { should include 'kill -USR1 $(cat /var/run/nginx_high_traf.pid)' }
  84. end
  85. describe file('/etc/logrotate.d/a_monthly_job') do
  86. it { should be_file }
  87. it { should be_owned_by 'root' }
  88. it { should be_grouped_into 'root' }
  89. its('mode') { should cmp '0644' }
  90. its('content') { should include '/var/log/a_service/*.log' }
  91. its('content') { should include 'monthly' }
  92. its('content') { should include 'missingok' }
  93. its('content') { should include 'rotate 12' }
  94. its('content') { should include 'compress' }
  95. its('content') { should include 'delaycompress' }
  96. its('content') { should include 'notifempty' }
  97. its('content') { should include 'create 640 root adm' }
  98. its('content') { should include 'sharedscripts' }
  99. end