Saltstack Official PHP Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

119 lines
4.2KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=jinja
  3. {# Template for installing packages #}
  4. {% from "php/map.jinja" import php with context %}
  5. {% from "php/macro.jinja" import sls_block %}
  6. {% set pkginfo = php.lookup.pkgs.get(state) %}
  7. {% set pkgs = [] %}
  8. {% set specials = [] %}
  9. {% set pillar_php_ng_version = salt['pillar.get']('php:ng:version', '7.0') %}
  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. {% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
  17. {% set first_version = pillar_php_ng_version[0]|string %}
  18. {% for other_version in pillar_php_ng_version %}
  19. {% set other_version_str = other_version|string %}
  20. {% do pkgs.append(pkg.replace(first_version, other_version_str)) %}
  21. {% endfor %}
  22. {% endif %}
  23. {% endif %}
  24. {% endfor %}
  25. {% else %}
  26. {% do pkgs.append(pkginfo) %}
  27. {% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
  28. {% set first_version = pillar_php_ng_version[0]|string %}
  29. {% for other_version in pillar_php_ng_version %}
  30. {% set other_version_str = other_version|string %}
  31. {% do pkgs.append(pkginfo.replace(first_version, other_version_str)) %}
  32. {% endfor %}
  33. {% endif %}
  34. {% endif %}
  35. {% if grains['os_family'] == "Debian" and (state == 'cli' or state == 'fpm' or state == 'php') %}
  36. {% set use_external_repo = salt['pillar.get']('php:use_external_repo', False) %}
  37. {% if use_external_repo %}
  38. {% if grains['os'] == 'Ubuntu' %}
  39. {% set external_repo_name = salt['pillar.get']('php:external_repo_name', 'ondrej/php') %}
  40. php_ppa_{{ state }}:
  41. pkgrepo.managed:
  42. - ppa: {{ external_repo_name }}
  43. - __env__:
  44. - LC_ALL: C.UTF-8
  45. - onlyif:
  46. - test ! -e /etc/apt/sources.list.d/ondrej-ubuntu-php-{{ grains['oscodename'] }}.list {# Trusty and Xenial use different naming schemas #}
  47. - test ! -e /etc/apt/sources.list.d/ondrej-php-{{ grains['oscodename'] }}.list {# Trusty and Xenial use different naming schemas #}
  48. - require_in:
  49. - pkg: php_install_{{ state }}
  50. pkg.latest:
  51. - name: {{ state }}
  52. - pkgs: {{ pkgs|json() }}
  53. - refresh: True
  54. - onchanges:
  55. - pkgrepo: php_ppa_{{ state }}
  56. {% else %}
  57. {% set external_repo_name = salt['pillar.get']('php:external_repo_name', 'packages.sury.org/php' ) %}
  58. php_repo_{{ state }}:
  59. pkg.installed:
  60. - name: apt-transport-https
  61. php_ppa_{{ state }}:
  62. pkgrepo.managed:
  63. - humanname: {{ external_repo_name }}
  64. - name: deb https://packages.sury.org/php/ {{ grains['oscodename'] }} main
  65. - file: /etc/apt/sources.list.d/ondrej-php.list
  66. - key_url: https://packages.sury.org/php/apt.gpg
  67. - __env__:
  68. - LC_ALL: C.UTF-8
  69. - onlyif:
  70. - test ! -e /etc/apt/sources.list.d/ondrej-php.list
  71. - require_in:
  72. - pkg: php_install_{{ state }}
  73. pkg.latest:
  74. - name: {{ state }}
  75. - pkgs: {{ pkgs|json() }}
  76. - refresh: True
  77. - onchanges:
  78. - pkgrepo: php_ppa_{{ state }}
  79. {% endif %}
  80. {% endif %}
  81. {% elif grains['os_family'] == "RedHat" and (state == 'cli' or state == 'fpm' or state == 'php') %}
  82. {% set use_scl_repo = salt['pillar.get']('php:use_scl_repo', False) %}
  83. {% set scl_php_version = salt['pillar.get']('php:scl_php_version', 71) %}
  84. {% set enable_php_repo = salt['pillar.get']('php:lookup:enable_php_repo', False) %}
  85. {% if use_scl_repo and grains['os'] == 'CentOS' %}
  86. php_centos_scl_enable_{{ state }}:
  87. pkg.installed:
  88. - name: centos-release-scl
  89. {% elif use_scl_repo and grains['os'] == 'RedHat' %}
  90. php_redhat_scl_enable_{{ state }}:
  91. cmd.run:
  92. - name: yum-config-manager --enable rhel-server-rhscl-{{ grains['osmajorrelease'] }}-rpms
  93. {% endif %}
  94. {% endif %}
  95. php_install_{{ state }}:
  96. pkg.installed:
  97. - name: {{ state }}
  98. - pkgs: {{ pkgs|json() }}
  99. {% if enable_php_repo is defined and enable_php_repo %}
  100. - enablerepo: {{ enable_php_repo }}
  101. {% endif %}
  102. {% for pkg in specials %}
  103. php_install_{{ state }}_{{ pkg.get('name') | replace("/", "-") }}:
  104. pkg.installed:
  105. {{ sls_block(pkg) }}
  106. {% endfor %}