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.

69 lines
2.1KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=sls
  3. {%- set tplroot = tpldir.split('/')[0] %}
  4. {%- set sls_service_running = tplroot ~ '.service.running' %}
  5. {%- set sls_package_install = tplroot ~ '.package.install' %}
  6. {%- from tplroot ~ "/map.jinja" import apache with context %}
  7. {%- set pagespeed_module = salt['pillar.get']('apache:pagespeed:module', 'pagespeed_prefork') %}
  8. include:
  9. - {{ sls_service_running }}
  10. - {{ sls_package_install }}
  11. {%- if grains['os_family'] in ('Suse', 'Debian',) %}
  12. apache-config-modules-pagespeed-pkg:
  13. pkg.installed:
  14. - name: {{ apache.mod_pagespeed }}
  15. - sources:
  16. - mod-pagespeed-stable: {{ apache.mod_pagespeed_source }}
  17. cmd.run:
  18. - name: a2enmod pagespeed
  19. - unless: ls {{ apache.moddir }}/pagespeed.load || egrep "^APACHE_MODULES=" /etc/sysconfig/apache2 | grep pagespeed
  20. - order: 255
  21. - require:
  22. - pkg: apache-config-modules-pagespeed-pkg
  23. - watch_in:
  24. - module: apache-service-running-restart
  25. - require_in:
  26. - module: apache-service-running-restart
  27. - module: apache-service-running-reload
  28. - service: apache-service-running
  29. {%- for dir in ['/var/cache/mod_pagespeed', '/var/log/pagespeed'] %}
  30. apache-config-modules-pagespeed-{{ dir }}-file-directory:
  31. file.directory:
  32. - name: {{ dir }}
  33. - makedirs: true
  34. - user: {{ apache.user }}
  35. - group: {{ apache.group }}
  36. - require:
  37. - pkg: apache-config-modules-pagespeed-pkg
  38. - user: {{ apache.user }}
  39. - group: {{ apache.group }}
  40. {%- endfor %}
  41. # Here we hardcode a logrotate entry to take care of the logs
  42. apache-config-modules-pagespeed-logrotate-file-managed:
  43. file.managed:
  44. - name: /etc/logrotate.d/pagespeed
  45. - contents: |
  46. /var/log/pagespeed/*.log {
  47. weekly
  48. missingok
  49. rotate 52
  50. compress
  51. delaycompress
  52. notifempty
  53. sharedscripts
  54. postrotate
  55. if /etc/init.d/apache2 status > /dev/null ; then \
  56. /etc/init.d/apache2 reload > /dev/null; \
  57. fi;
  58. endscript
  59. }
  60. {%- endif %}