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.

62 lines
1.9KB

  1. {% from "php/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
  11. {% if grains['os_family'] == 'FreeBSD' %}
  12. - php.filter
  13. - php.hash
  14. - php.json
  15. - php.mbstring
  16. - php.openssl
  17. - php.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