Saltstack Official PHP Formula
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

101 line
3.1KB

  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. {% elif grains['os_family'] == "RedHat" and (state == 'cli' or state == 'fpm' or state == 'php') %}
  67. {% set use_scl_repo = salt['pillar.get']('php:use_scl_repo', False) %}
  68. {% set scl_php_version = salt['pillar.get']('php:scl_php_version', 71) %}
  69. {% if use_scl_repo and grains['os'] == 'CentOS' %}
  70. php_centos_scl_enable_{{ state }}:
  71. pkg.installed:
  72. - name: centos-release-scl
  73. {% elif use_scl_repo and grains['os'] == 'RedHat' %}
  74. php_redhat_scl_enable_{{ state }}:
  75. cmd.run:
  76. - name: yum-config-manager --enable rhel-server-rhscl-{{ grains['osmajorrelease'] }}-rpms
  77. {% endif %}
  78. {% endif %}
  79. php_install_{{ state }}:
  80. pkg.installed:
  81. - name: {{ state }}
  82. - pkgs: {{ pkgs|json() }}
  83. {% for pkg in specials %}
  84. php_install_{{ state }}_{{ pkg.get('name') | replace("/", "-") }}:
  85. pkg.installed:
  86. {{ sls_block(pkg) }}
  87. {% endfor %}