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

65 line
1.9KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=jinja
  3. {# Template for installing packages #}
  4. {% from "php/ng/map.jinja" import php with context %}
  5. {% from "php/ng/macro.jinja" import sls_block %}
  6. {% set pkginfo = php.lookup.pkgs.get(state) %}
  7. {% set phpng_version = salt['pillar.get']('php:ng:version', '7.0')|string %}
  8. {% set pkgs = [] %}
  9. {% set specials = [] %}
  10. {% if pkginfo is iterable and pkginfo is not string %}
  11. {% for pkg in pkginfo %}
  12. {% if pkg is mapping %}
  13. {% do specials.append(pkg) %}
  14. {% else %}
  15. {% do pkgs.append(pkg) %}
  16. {% endif %}
  17. {% endfor %}
  18. {% else %}
  19. {% do pkgs.append(pkginfo) %}
  20. {% endif %}
  21. {% if grains['os_family'] == "Debian" and (state == 'cli' or state == 'fpm' or state == 'php') %}
  22. {% set use_external_repo = salt['pillar.get']('php:use_external_repo', False) %}
  23. {% if use_external_repo %}
  24. {% set external_repo_name = salt['pillar.get']('php:external_repo_name', 'ondrej/php') %}
  25. {% set current_php = salt['alternatives.show_current']('php') %}
  26. php_ppa_{{ state }}:
  27. pkgrepo.managed:
  28. - ppa: {{ external_repo_name }}
  29. - env:
  30. - LC_ALL: C.UTF-8
  31. - onlyif:
  32. - test ! -e /etc/apt/sources.list.d/ondrej-ubuntu-php-{{ grains['oscodename'] }}.list {# Trusty and Xenial use different naming schemas #}
  33. - test ! -e /etc/apt/sources.list.d/ondrej-php-{{ grains['oscodename'] }}.list {# Trusty and Xenial use different naming schemas #}
  34. - require_in:
  35. - pkg: php_install_{{ state }}
  36. pkg.latest:
  37. - name: {{ state }}
  38. - pkgs: {{ pkgs|json() }}
  39. - refresh: True
  40. - onchanges:
  41. - pkgrepo: php_ppa_{{ state }}
  42. {% endif %}
  43. {% endif %}
  44. php_install_{{ state }}:
  45. pkg.installed:
  46. - name: {{ state }}
  47. - pkgs: {{ pkgs|json() }}
  48. {% for pkg in specials %}
  49. php_install_{{ state }}_{{ pkg.get('name') }}:
  50. pkg.installed:
  51. {{ sls_block(pkg) }}
  52. {% endfor %}