library/roles/composer: Role that installs composer, a php plugins manager.

This commit is contained in:
Andrea Dell'Amico 2016-08-04 18:49:50 +02:00
parent 83720dab17
commit 6ac18a217a
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,11 @@
---
# See https://getcomposer.org/download
#
composer_install: True
composer_get_url: https://getcomposer.org/installer
composer_dest_dir: /usr/local/bin
composer_exec_name: composer
composer_signature_type: SHA384
composer_signature: 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae'
composer_setup: composer-setup.php

23
composer/tasks/main.yml Normal file
View File

@ -0,0 +1,23 @@
---
- block:
- name: Install the script that downloads and installs composer
template: src=composer-installer.j2 dest=/usr/local/sbin/composer-installer owner=root group=root mode=0750
- name: Install composer
shell: /usr/local/sbin/composer-installer
args:
creates: '{{ composer_dest_dir }}/{{ composer_exec_name }}'
when: composer_install
tags: [ 'php', 'composer' ]
- block:
- name: Remove the composer installer script
file: dest=/usr/local/sbin/composer-installer state=absent
- name: Remove composer
file: dest='{{ composer_dest_dir }}/{{ composer_exec_name }}' state=absent
when: not composer_install
tags: [ 'php', 'composer' ]

View File

@ -0,0 +1,10 @@
#!/bin/bash
php -r "copy('{{ composer_get_url }}', '{{ composer_setup }}');"
php -r "if (hash_file('{{ composer_signature_type }}', '{{ composer_setup }}') === '{{ composer_signature }}') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('{{ composer_setup }}'); } echo PHP_EOL;"
php {{ composer_setup }} --install-dir={{ composer_dest_dir }} --filename={{ composer_exec_name }}
php -r "unlink('{{ composer_setup }}');"
chmod 755 {{ composer_dest_dir }}/{{ composer_exec_name }}
exit 0