library/roles/drupal-org: Add tasks that install drush. Add composer as dependency.

This commit is contained in:
Andrea Dell'Amico 2016-08-04 18:50:07 +02:00
parent 6ac18a217a
commit 235da6d111
5 changed files with 92 additions and 74 deletions

View File

@ -5,6 +5,7 @@ drupal_version: '{{ drupal_major_ver }}.1.7'
drupal_dist_name: 'drupal-{{ drupal_version }}'
drupal_dist_file: '{{ drupal_dist_name }}.tar.gz'
drupal_tar_url: 'http://ftp.drupal.org/files/projects/{{ drupal_dist_file }}'
drupal_php_user: drupal
drupal_download_dir: /srv/drupal
drupal_install_dir: /var/www
@ -25,3 +26,5 @@ drupal_php_prereq:
- php-xml-serializer
- imagemagick
drupal_install_drush: True
drupal_drush_version: '{{ drupal_major }}.*'

4
drupal-org/meta/main.yml Normal file
View File

@ -0,0 +1,4 @@
---
dependencies:
- { role: '../../library/roles/composer', when: drupal_install_drush }

View File

@ -0,0 +1,75 @@
---
- name: Install the drupal php prerequisites
apt: name={{ item }} state=latest update_cache=yes cache_valid_time=3600
with_items: '{{ drupal_php_prereq }}'
tags: drupal
- name: Ensure that the download and install dirs exist
file: path={{ item }} state=directory
with_items:
- '{{ drupal_download_dir }}'
- '{{ drupal_install_dir }}'
tags: drupal
- name: Download the drupal tar file
get_url: url={{ drupal_tar_url }} dest={{ drupal_download_dir }}
when: not drupal_install_deb
register: drupal_download
tags: drupal
- name: Install the drupal deb package
apt: name=drupal state=installed
when: drupal_install_deb
tags: [ 'drupal', 'drupal_deb' ]
- name: Unpack the drupal tar file
unarchive: copy=no src={{ drupal_download_dir }}/{{ drupal_dist_file }} dest={{ drupal_download_dir }}
when: ( drupal_download | changed )
tags: drupal
- name: Move the drupal files to the right place
command: cp -a {{ drupal_download_dir }}/{{ drupal_dist_name }} {{ drupal_install_dir }}/{{ item.virthost }}
args:
creates: '{{ drupal_install_dir }}/{{ item.virthost }}/index.php'
with_items: '{{ phpfpm_pools }}'
when: ( drupal_download | changed )
register: unpack_drupal
tags: drupal
- name: Create the default settings file
command: cp {{ drupal_install_dir }}/{{ item.virthost }}/sites/default/default.settings.php {{ drupal_install_dir }}/{{ item.virthost }}/sites/default/settings.php
args:
creates: '{{ drupal_install_dir }}/{{ item.virthost }}/sites/default/settings.php'
with_items: '{{ phpfpm_pools }}'
when:
- ( unpack_drupal | changed )
- '{{ drupal_major_ver }} >= 8'
tags: drupal
- name: Create the default services file
command: cp {{ drupal_install_dir }}/{{ item.virthost }}/sites/default/default.services.yml {{ drupal_install_dir }}/{{ item.virthost }}/sites/default/services.yml
args:
creates: '{{ drupal_install_dir }}/{{ item.virthost }}/sites/default/services.yml'
with_items: '{{ phpfpm_pools }}'
when:
- ( unpack_drupal | changed )
- '{{ drupal_major_ver }} >= 8'
tags: drupal
- name: Create the files directory
file: dest={{ drupal_install_dir }}/{{ item.virthost }}/sites/default/files owner={{ item.user }} group={{ item.group }} mode=0770 state=directory
with_items: '{{ phpfpm_pools }}'
when: ( unpack_drupal | changed )
tags: drupal
- name: Set the correct ownership of the drupal files
file: dest={{ drupal_install_dir }}/{{ item.virthost }} owner={{ item.user }} group={{ item.group }} recurse=yes state=directory
with_items: '{{ phpfpm_pools }}'
when: ( unpack_drupal | changed )
tags: drupal
- name: Remove the original drupal unpacked distribution
file: dest={{ drupal_download_dir }}/{{ drupal_dist_name }} state=absent
when: ( unpack_drupal | changed )
tags: drupal

View File

@ -0,0 +1,7 @@
---
- name: Install drush
become: True
become_user: '{{ item.user }}'
composer: command=require arguments=drush/drush:{{ drupal_drush_version }} prefer_dist=yes working_dir={{ item.doc_root }}
with_items: '{{ phpfpm_pools }}'
tags: ['drupal', 'drush' ]

View File

@ -1,75 +1,4 @@
---
- name: Install the drupal php prerequisites
apt: name={{ item }} state=latest update_cache=yes cache_valid_time=3600
with_items: '{{ drupal_php_prereq }}'
tags: drupal
- name: Ensure that the download and install dirs exist
file: path={{ item }} state=directory
with_items:
- '{{ drupal_download_dir }}'
- '{{ drupal_install_dir }}'
tags: drupal
- name: Download the drupal tar file
get_url: url={{ drupal_tar_url }} dest={{ drupal_download_dir }}
when: not drupal_install_deb
register: drupal_download
tags: drupal
- name: Install the drupal deb package
apt: name=drupal state=installed
when: drupal_install_deb
tags: [ 'drupal', 'drupal_deb' ]
- name: Unpack the drupal tar file
unarchive: copy=no src={{ drupal_download_dir }}/{{ drupal_dist_file }} dest={{ drupal_download_dir }}
when: ( drupal_download | changed )
tags: drupal
- name: Move the drupal files to the right place
command: cp -a {{ drupal_download_dir }}/{{ drupal_dist_name }} {{ drupal_install_dir }}/{{ item.virthost }}
args:
creates: '{{ drupal_install_dir }}/{{ item.virthost }}/index.php'
with_items: '{{ phpfpm_pools }}'
when: ( drupal_download | changed )
register: unpack_drupal
tags: drupal
- name: Create the default settings file
command: cp {{ drupal_install_dir }}/{{ item.virthost }}/sites/default/default.settings.php {{ drupal_install_dir }}/{{ item.virthost }}/sites/default/settings.php
args:
creates: '{{ drupal_install_dir }}/{{ item.virthost }}/sites/default/settings.php'
with_items: '{{ phpfpm_pools }}'
when:
- ( unpack_drupal | changed )
- '{{ drupal_major_ver }} >= 8'
tags: drupal
- name: Create the default services file
command: cp {{ drupal_install_dir }}/{{ item.virthost }}/sites/default/default.services.yml {{ drupal_install_dir }}/{{ item.virthost }}/sites/default/services.yml
args:
creates: '{{ drupal_install_dir }}/{{ item.virthost }}/sites/default/services.yml'
with_items: '{{ phpfpm_pools }}'
when:
- ( unpack_drupal | changed )
- '{{ drupal_major_ver }} >= 8'
tags: drupal
- name: Create the files directory
file: dest={{ drupal_install_dir }}/{{ item.virthost }}/sites/default/files owner={{ item.user }} group={{ item.group }} mode=0770 state=directory
with_items: '{{ phpfpm_pools }}'
when: ( unpack_drupal | changed )
tags: drupal
- name: Set the correct ownership of the drupal files
file: dest={{ drupal_install_dir }}/{{ item.virthost }} owner={{ item.user }} group={{ item.group }} recurse=yes state=directory
with_items: '{{ phpfpm_pools }}'
when: ( unpack_drupal | changed )
tags: drupal
- name: Remove the original drupal unpacked distribution
file: dest={{ drupal_download_dir }}/{{ drupal_dist_name }} state=absent
when: ( unpack_drupal | changed )
tags: drupal
- include: drupal-main.yml
- include: drush.yml
when: drupal_install_drush