From 266d63ffb72493585a400429c65a56f1ce22f53e Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 15 Oct 2015 18:43:02 +0200 Subject: [PATCH] library/roles/drupal-org: First attempt at a drupal playbook. --- drupal-org/defaults/main.yml | 20 +++++++++++++++ drupal-org/tasks/main.yml | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 drupal-org/defaults/main.yml create mode 100644 drupal-org/tasks/main.yml diff --git a/drupal-org/defaults/main.yml b/drupal-org/defaults/main.yml new file mode 100644 index 00000000..4ca56537 --- /dev/null +++ b/drupal-org/defaults/main.yml @@ -0,0 +1,20 @@ +--- +drupal_install_deb: False +drupal_dist_name: drupal-8.0.0-rc1 +drupal_dist_file: '{{ drupal_dist_name }}.tar.gz' +drupal_tar_url: 'http://ftp.drupal.org/files/projects/{{ drupal_dist_file }}' +drupal_download_dir: /srv/drupal +drupal_install_dir: /var/www + +drupal_php_prereq: + - php5-json + - php5-intl + - php5-cli + - php5-mysqlnd + - php5-gd + - php-apc + - php-pear + - php-date + - php-xml-serializer + - imagemagick + diff --git a/drupal-org/tasks/main.yml b/drupal-org/tasks/main.yml new file mode 100644 index 00000000..e7c8bf9d --- /dev/null +++ b/drupal-org/tasks/main.yml @@ -0,0 +1,49 @@ +--- +- name: Install the drupal php prerequisites + apt: name={{ item }} state=present + 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: 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 + command: rm -fr {{ drupal_download_dir }}/{{ drupal_dist_name }} + when: ( unpack_drupal | changed ) + tags: drupal +