Add all files needed to bring up VM and run agaric.com locally

This commit is contained in:
benjamin melançon 2018-08-20 10:45:20 -04:00
parent 52c8b60bac
commit 4d2bc0ee24
742 changed files with 24037 additions and 0 deletions

View file

@ -0,0 +1,26 @@
---
# Shims for Drupal VM backwards compatibility. To be removed by 2018.
- name: build_makefile shim
set_fact:
drupal_build_makefile: "{{ build_makefile }}"
when: build_makefile|default('')
- name: build_composer shim
set_fact:
drupal_build_composer: "{{ build_composer }}"
when: build_composer|default('')
- name: build_composer_project shim
set_fact:
drupal_build_composer_project: "{{ build_composer_project }}"
when: build_composer_project|default('')
- name: install_site shim
set_fact:
drupal_install_site: "{{ install_site }}"
when: install_site|default('')
- name: drupalvm_database shim
set_fact:
drupal_db_backend: "{{ drupalvm_database }}"
when: drupalvm_database|default('')

View file

@ -0,0 +1,41 @@
---
- name: Delete old /tmp/composer-project
file:
path: "/tmp/composer-project"
state: absent
when: not drupal_site_exists
- name: Generate Drupal project with composer package in /tmp/composer-project (this may take a while).
command: >
{{ composer_path }} create-project
{{ drupal_composer_project_package }} /tmp/composer-project
{{ drupal_composer_project_options|default('--prefer-dist --no-interaction') }}
when: not drupal_site_exists
become: no
environment:
COMPOSER_PROCESS_TIMEOUT: 1200
- name: Ensure drupal_composer_install_dir directory has proper permissions.
file:
path: "{{ drupal_composer_install_dir }}"
state: directory
owner: "{{ drupal_core_owner }}"
group: "{{ drupal_core_owner }}"
mode: 0775
when: not drupal_site_exists
failed_when: false
- name: Move Drupal project files to drupal_composer_install_dir (this may take a while).
command: >
cp -r /tmp/composer-project/. {{ drupal_composer_install_dir }}/
creates={{ drupal_core_path }}/index.php
become: no
when: not drupal_site_exists
- name: Install dependencies with composer require (this may take a while).
composer:
command: require
arguments: "{{ item }}"
working_dir: "{{ drupal_composer_install_dir }}"
with_items: "{{ drupal_composer_dependencies|default([]) }}"
become: no

View file

@ -0,0 +1,37 @@
---
- name: Ensure drupal_composer_install_dir directory exists.
file:
path: "{{ drupal_composer_install_dir }}"
state: directory
mode: 0775
become: no
when: drupal_composer_path and not drupal_site_exists
# Use copy-and-move to prevent issues in Windows with VirtualBox. See:
# https://github.com/ansible/ansible/issues/9526#issuecomment-62336962
- name: Copy composer.json into temporary location.
copy:
src: "{{ drupal_composer_path }}"
dest: "/tmp/drupalvm-composer.json"
when: drupal_composer_path and not drupal_site_exists
become: no
- name: Move composer.json into place.
command: "mv /tmp/drupalvm-composer.json {{ drupal_composer_install_dir }}/composer.json"
when: drupal_composer_path and not drupal_site_exists
become: no
- name: Run composer install (this may take a while).
composer:
command: install
working_dir: "{{ drupal_composer_install_dir }}"
when: not drupal_site_exists
become: no
- name: Install dependencies with composer require (this may take a while).
composer:
command: require
arguments: "{{ item }}"
working_dir: "{{ drupal_composer_install_dir }}"
with_items: "{{ drupal_composer_dependencies|default([]) }}"
become: no

View file

@ -0,0 +1,34 @@
---
- name: Copy drush makefile into place.
copy:
src: "{{ drush_makefile_path }}"
dest: /tmp/drupal.make.yml
when: not drupal_site_exists
- name: Ensure drupal_core_path directory exists.
file:
path: "{{ drupal_core_path }}"
state: directory
recurse: yes
mode: 0775
become: no
when: not drupal_site_exists
- name: Generate Drupal site with drush makefile.
command: >
{{ drush_path }} make -y /tmp/drupal.make.yml {{ drush_make_options }}
chdir={{ drupal_core_path }}
when: not drupal_site_exists
become: no
- name: Check if a composer.json file is present.
stat: "path={{ drupal_core_path }}/composer.json"
register: drupal_core_composer_file
when: not drupal_site_exists
- name: Run composer install if composer.json is present.
command: >
composer install
chdir={{ drupal_core_path }}
when: not drupal_site_exists and drupal_core_composer_file.stat.exists
become: no

View file

@ -0,0 +1,34 @@
---
- name: Ensure drupal_deploy_dir directory exists.
file:
path: "{{ drupal_deploy_dir }}"
state: directory
mode: 0775
owner: "{{ drupal_core_owner }}"
group: "{{ drupal_core_owner }}"
when: drupal_composer_path and not drupal_site_exists
- name: Check out Drupal to the docroot.
git:
repo: "{{ drupal_deploy_repo }}"
version: "{{ drupal_deploy_version }}"
update: "{{ drupal_deploy_update }}"
force: yes
dest: "{{ drupal_deploy_dir }}"
accept_hostkey: "{{ drupal_deploy_accept_hostkey }}"
register: drupal_deploy_repo_updated
notify: clear opcache
become: no
- name: Check if a composer.json file is present.
stat: "path={{ drupal_deploy_dir }}/composer.json"
register: drupal_deploy_composer_file
- name: Run composer install if composer.json is present.
composer:
command: install
working_dir: "{{ drupal_deploy_dir }}"
when:
- drupal_deploy_composer_file.stat.exists == true
- drupal_deploy_composer_install == true
become: no

View file

@ -0,0 +1,43 @@
---
- name: Check if site is already installed.
command: "{{ drush_path }} --root={{ drupal_core_path }} status bootstrap"
args:
chdir: "{{ drupal_core_path }}"
register: drupal_site_installed
failed_when: "drupal_site_installed.stdout is undefined"
changed_when: false
become: no
# See: https://www.drupal.org/node/2569365#comment-11680807
- name: Configure database correctly if using PostgreSQL.
command: psql -c "ALTER DATABASE {{ drupal_db_name }} SET bytea_output = 'escape';"
when: "('Drupal bootstrap' not in drupal_site_installed.stdout) and (drupal_db_backend == 'pgsql')"
become: yes
become_user: "{{ postgresql_user }}"
# See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509
vars:
ansible_ssh_pipelining: true
- name: Install Drupal with drush.
command: >
{{ drush_path }} site-install {{ drupal_install_profile | default('standard') }} -y
--root={{ drupal_core_path }}
--site-name="{{ drupal_site_name }}"
--account-name={{ drupal_account_name }}
--account-pass={{ drupal_account_pass }}
--db-url={{ drupal_db_backend }}://{{ drupal_db_user }}:{{ drupal_db_password }}@{{ drupal_db_host }}/{{ drupal_db_name }}
{{ drupal_site_install_extra_args | join(" ") }}
args:
chdir: "{{ drupal_core_path }}"
notify: clear opcache
when: "'Drupal bootstrap' not in drupal_site_installed.stdout"
become: no
- name: Install configured modules with drush.
command: >
{{ drush_path }} pm-enable -y {{ drupal_enable_modules | join(" ") }}
--root={{ drupal_core_path }}
args:
chdir: "{{ drupal_core_path }}"
when: ('Drupal bootstrap' not in drupal_site_installed.stdout) and drupal_enable_modules
become: no

View file

@ -0,0 +1,62 @@
---
- name: Add backwards-compatibility shims.
include: backwards-compatibility.yml
static: no
- name: Check if Drupal is already set up.
stat: "path={{ drupal_core_path }}/index.php"
register: drupal_site
ignore_errors: true
- name: Define drush_path if it's not already defined.
set_fact:
drush_path: drush
when: drush_path is not defined
- name: Define drupal_site_exists.
set_fact:
drupal_site_exists: "{{ drupal_site.stat.exists|default(false) }}"
# Deploy Drupal if configured.
- include: tasks/deploy.yml
when: drupal_deploy
- name: Define drupal_deploy_updated
set_fact:
drupal_deploy_updated: "{{ drupal_deploy_repo_updated.changed|default(false) }}"
# Run update tasks if Drupal was updated.
- include: tasks/update.yml
when: drupal_deploy_updated and drupal_site_exists
static: no
# Build makefile if configured.
- include: tasks/build-makefile.yml
when: drupal_build_makefile
static: no
# Build with composer if configured.
- include: tasks/build-composer.yml
when: drupal_build_composer
static: no
# Build a composer project if configured.
- include: tasks/build-composer-project.yml
when: drupal_build_composer_project
static: no
# Set Drush variables.
- name: Check if a project specific Drush binary exists.
stat: "path={{ drupal_composer_install_dir }}/vendor/drush/drush/drush"
register: drush_vendor_bin
ignore_errors: true
- name: Use project specific Drush if available.
set_fact:
drush_path: "{{ drupal_composer_install_dir }}/vendor/drush/drush/drush"
when: drush_vendor_bin.stat.exists
# Install site if configured.
- include: tasks/install-site.yml
when: drupal_install_site
static: no

View file

@ -0,0 +1,13 @@
---
- name: Run database updates.
command: "{{ drush_path }} updatedb -y"
args:
chdir: "{{ drupal_core_path }}"
# TODO: Import configuration if configured?
# TODO: Other commands if configured?
- name: Rebuild Drupal caches.
command: "{{ drush_path }} cache-rebuild --quiet"
args:
chdir: "{{ drupal_core_path }}"