-
Notifications
You must be signed in to change notification settings - Fork 1
/
composer.sls
54 lines (48 loc) · 1.89 KB
/
composer.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# TODO add signature check like described on https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
#
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
# ensure php is installed with zip extension and we have git to clone repos
composer_php:
pkg.installed:
- pkgs:
- unzip
- git
{% set composer_home = pillar.get('composer-home', '/root/.config/composer')%}
composer_home:
file.directory:
- name: '{{ composer_home }}'
- makedirs: True
# install composer
composer_installed:
cmd.run:
- name: cd /usr/local/bin && curl -sS https://getcomposer.org/installer | php && ln -sf composer.phar composer
- env:
- COMPOSER_HOME: '{{composer_home}}'
- COMPOSER_ALLOW_SUPERUSER: {{ pillar.get('composer-allow-superuser', 1) }}
- unless: test -x /usr/local/bin/composer
- require:
- pkg: composer_php
- file: composer_home
# install composer plugins
{% for plugin in pillar.get('composer-plugins', []) %}
composer_{{plugin.name}}:
cmd.run:
- name: '/usr/local/bin/composer global require "{{plugin.src}}"'
- env:
- COMPOSER_HOME: '{{composer_home}}'
- COMPOSER_ALLOW_SUPERUSER: {{pillar.get('composer-allow-superuser', 1)}}
- unless: /usr/local/bin/composer global show | grep {{plugin.name}}
- require:
- cmd: composer_installed
{% endfor %}
{% if pillar.get('composer-github-token', None) != None %}
composer_github_token:
cmd.run:
- name: composer config --global github-oauth.github.com {{ pillar['composer-github-token'] }}
- env:
- COMPOSER_HOME: '{{composer_home}}'
- COMPOSER_ALLOW_SUPERUSER: {{pillar.get('composer-allow-superuser', 1)}}
- unless: test $(composer config --global github-oauth.github.com) = "{{ pillar['composer-github-token'] }}"
- require:
- cmd: composer_installed
{% endif %}