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.

80 line
2.6KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=jinja
  3. {%- set tplroot = tpldir.split('/')[0] %}
  4. {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
  5. {%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
  6. {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
  7. {%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
  8. {%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
  9. {%- import_yaml tplroot ~ "/oscodenamemap.yaml" as oscodename %}
  10. {%- import_yaml tplroot ~ "/modsecurity.yaml" as modsec %}
  11. {#- Retrieve the config dict only once #}
  12. {%- set _config = salt['config.get'](tplroot, default={}) %}
  13. {%- set defaults = salt['grains.filter_by'](
  14. default_settings,
  15. default=tplroot,
  16. merge=salt['grains.filter_by'](
  17. osarchmap,
  18. grain='osarch',
  19. merge=salt['grains.filter_by'](
  20. osfamilymap,
  21. grain='os_family',
  22. merge=salt['grains.filter_by'](
  23. osmap,
  24. grain='os',
  25. merge=salt['grains.filter_by'](
  26. oscodename,
  27. grain='oscodename',
  28. merge=salt['grains.filter_by'](
  29. osfingermap,
  30. grain='osfinger',
  31. merge=salt['grains.filter_by'](
  32. modsec,
  33. grain='os_family',
  34. merge=salt['grains.filter_by'](
  35. _config,
  36. default='lookup'
  37. )
  38. )
  39. )
  40. )
  41. )
  42. )
  43. )
  44. )
  45. %}
  46. {%- set config = salt['grains.filter_by'](
  47. {'defaults': defaults},
  48. default='defaults',
  49. merge=_config
  50. )
  51. %}
  52. {%- set apache = config %}
  53. {#- Post-processing for specific non-YAML customisations #}
  54. {%- if grains.os_family == 'MacOS' %}
  55. {%- set rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %}
  56. {%- set rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
  57. {%- do apache.update({'rootuser': rootgroup}) %}
  58. {%- do apache.update({'rootgroup': rootgroup}) %}
  59. {%- elif grains.os_family == 'Windows' %}
  60. {%- set rootuser = salt['cmd.run']("id -un") %}
  61. {%- do apache.update({'rootuser': rootuser}) %}
  62. {%- endif %}
  63. {# legacy pillar support #}
  64. {%- if 'server' in apache.lookup and apache.lookup.server is string %}
  65. {%- do apache.pkg.update({'name': apache.server}) %}
  66. {%- endif %}
  67. {%- if 'service' in apache.lookup and apache.lookup.service is string %}
  68. {%- do apache.service.update({'name': apache.service}) %}
  69. {%- endif %}
  70. {%- if 'configfile' in apache and apache.configfile is string %}
  71. {%- do apache.update({'config': apache.configfile}) %}
  72. {%- endif %}