diff --git a/composer/defaults/main.yml b/composer/defaults/main.yml new file mode 100644 index 00000000..0a4572dd --- /dev/null +++ b/composer/defaults/main.yml @@ -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 + diff --git a/composer/tasks/main.yml b/composer/tasks/main.yml new file mode 100644 index 00000000..7f088751 --- /dev/null +++ b/composer/tasks/main.yml @@ -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' ] + diff --git a/composer/templates/composer-installer.j2 b/composer/templates/composer-installer.j2 new file mode 100644 index 00000000..54406df2 --- /dev/null +++ b/composer/templates/composer-installer.j2 @@ -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