Saltstack Official PHP Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

62 lines
1.9KB

  1. {% from "php/ng/map.jinja" import php with context %}
  2. {% set install_file = php.lookup.pkgs.local_bin + '/' + php.lookup.pkgs.composer_bin %}
  3. {% if not salt['config.get']('sudo_user') %}
  4. {% set salt_user = salt['config.get']('user', 'root') %}
  5. {% else %}
  6. {% set salt_user = salt['config.get']('sudo_user', 'root') %}
  7. {% endif %}
  8. {% set salt_user_home = salt['user.info'](salt_user).get('home', '/root') %}
  9. include:
  10. - php.ng
  11. {% if grains['os_family'] == 'FreeBSD' %}
  12. - php.ng.filter
  13. - php.ng.hash
  14. - php.ng.json
  15. - php.ng.mbstring
  16. - php.ng.openssl
  17. - php.ng.phar
  18. {% endif %}
  19. get-composer:
  20. file.managed:
  21. - name: {{ php.lookup.pkgs.temp_dir }}/installer
  22. - mode: 0755
  23. - unless: test -f {{ install_file }}
  24. - source: https://getcomposer.org/installer
  25. - source_hash: https://composer.github.io/installer.sig
  26. - require:
  27. - pkg: php
  28. install-composer:
  29. cmd.run:
  30. - name: php {{ php.lookup.pkgs.temp_dir }}/installer --filename={{ php.lookup.pkgs.composer_bin }} --install-dir={{ php.lookup.pkgs.local_bin }}
  31. - unless: test -f {{ install_file }}
  32. - env:
  33. - HOME: {{ salt_user_home }}
  34. - require:
  35. - file: get-composer
  36. # Get composer version date and check if older than 60day (defaultvalue of COMPOSER_DEV_WARNING_TIME)
  37. # then it's time to run `composer selfupdate`
  38. #
  39. # It would be nice if composer had a command line switch to get this, but it doesn't,
  40. # and so we just grep for it.
  41. #
  42. update-composer:
  43. cmd.run:
  44. - name: "{{ install_file }} selfupdate"
  45. {% if grains['os_family'] == 'FreeBSD' %}
  46. - unless: test $(date -v+60d -j -f "%Y-%m-%d %H:%M:%S" "$({{ install_file }} --version | cut -d ' ' -f 4,5)" "+%s") -gt $(date "+%s")
  47. {% else %}
  48. - unless: test $(date -d "60 days $({{ install_file }} --version | cut -d ' ' -f 4,5)" "+%s") -gt $(date "+%s")
  49. {% endif %}
  50. - cwd: {{ php.lookup.pkgs.local_bin }}
  51. - env:
  52. - HOME: {{ salt_user_home }}
  53. - require:
  54. - cmd: install-composer