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.

89 line
2.5KB

  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 pkgs = [] %}
  8. {% set specials = [] %}
  9. {% if pkginfo is iterable and pkginfo is not string %}
  10. {% for pkg in pkginfo %}
  11. {% if pkg is mapping %}
  12. {% do specials.append(pkg) %}
  13. {% else %}
  14. {% do pkgs.append(pkg) %}
  15. {% endif %}
  16. {% endfor %}
  17. {% else %}
  18. {% do pkgs.append(pkginfo) %}
  19. {% endif %}
  20. {% if grains['os_family'] == "Debian" and (state == 'cli' or state == 'fpm' or state == 'php') %}
  21. {% set use_external_repo = salt['pillar.get']('php:use_external_repo', False) %}
  22. {% if use_external_repo %}
  23. {% if grains['os'] == 'Ubuntu' %}
  24. {% set external_repo_name = salt['pillar.get']('php:external_repo_name', 'ondrej/php') %}
  25. php_ppa_{{ state }}:
  26. pkgrepo.managed:
  27. - ppa: {{ external_repo_name }}
  28. - env:
  29. - LC_ALL: C.UTF-8
  30. - onlyif:
  31. - test ! -e /etc/apt/sources.list.d/ondrej-ubuntu-php-{{ grains['oscodename'] }}.list {# Trusty and Xenial use different naming schemas #}
  32. - test ! -e /etc/apt/sources.list.d/ondrej-php-{{ grains['oscodename'] }}.list {# Trusty and Xenial use different naming schemas #}
  33. - require_in:
  34. - pkg: php_install_{{ state }}
  35. pkg.latest:
  36. - name: {{ state }}
  37. - pkgs: {{ pkgs|json() }}
  38. - refresh: True
  39. - onchanges:
  40. - pkgrepo: php_ppa_{{ state }}
  41. {% else %}
  42. {% set external_repo_name = salt['pillar.get']('php:external_repo_name', 'packages.sury.org/php' ) %}
  43. php_repo_{{ state }}:
  44. pkg.installed:
  45. - name: apt-transport-https
  46. php_ppa_{{ state }}:
  47. pkgrepo.managed:
  48. - humanname: {{ external_repo_name }}
  49. - name: deb https://packages.sury.org/php/ {{ grains['oscodename'] }} main
  50. - file: /etc/apt/sources.list.d/ondrej-php.list
  51. - key_url: https://packages.sury.org/php/apt.gpg
  52. - env:
  53. - LC_ALL: C.UTF-8
  54. - onlyif:
  55. - test ! -e /etc/apt/sources.list.d/ondrej-php.list
  56. - require_in:
  57. - pkg: php_install_{{ state }}
  58. pkg.latest:
  59. - name: {{ state }}
  60. - pkgs: {{ pkgs|json() }}
  61. - refresh: True
  62. - onchanges:
  63. - pkgrepo: php_ppa_{{ state }}
  64. {% endif %}
  65. {% endif %}
  66. {% endif %}
  67. php_install_{{ state }}:
  68. pkg.installed:
  69. - name: {{ state }}
  70. - pkgs: {{ pkgs|json() }}
  71. {% for pkg in specials %}
  72. php_install_{{ state }}_{{ pkg.get('name') | replace("/", "-") }}:
  73. pkg.installed:
  74. {{ sls_block(pkg) }}
  75. {% endfor %}