Saltstack Official PHP Formula
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

107 Zeilen
3.3KB

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