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

272
provisioning/box/config.yml Normal file
View file

@ -0,0 +1,272 @@
---
# Suggested settings to adjust:
# vagrant_hostname
# vagrant_machine_name
# drupal_site_name
# theme (set if you are building from sass)
# See ../box/default.config.yml for additional settings
# which can be overridden here.
vagrant_box: geerlingguy/debian9
# If you need to run multiple instances of Drupal VM, set a unique hostname,
# and machine name
vagrant_hostname: agaric.local
vagrant_machine_name: agaric-com-vm
# You can specify an IP, or else the vagrant-auto_network will set it for you:
vagrant_ip: 0.0.0.0
vagrant_synced_folders:
# A list of synced folders, with the keys 'local_path', 'destination', and
# a 'type' of [nfs|rsync|smb] (leave empty for slow native shares). See
# http://docs.drupalvm.com/en/latest/getting-started/syncing-folders/ for more.
# The first synced folder will be used for the default Drupal installation, if
# any of the build_* settings are 'true'. By default the folder is set to
# the drupal-vm folder.
- local_path: .
destination: /var/www/drutopia
type: nfs
create: true
# Ensure vagrant plugins are installed.
vagrant_plugins:
- name: vagrant-vbguest
- name: vagrant-hostsupdater
- name: vagrant-auto_network
# Setting theme to empty will skip sass step:
# (drutopia's default theme, octavia, is included)
theme:
# Set this to 'false' if you are using a different site deployment strategy and
# would like to configure 'vagrant_synced_folders' and 'apache_vhosts' manually.
drupal_build_makefile: false
drush_makefile_path: "{{ config_dir }}/drupal.make.yml"
drush_make_options: "--no-gitinfofile"
# Set 'build_makefile' to 'false' and this to 'true' if you are using a
# composer based site deployment strategy.
drupal_build_composer: false
drupal_composer_path: false #"{{ config_dir }}/drupal.composer.json"
drupal_composer_install_dir: "/var/www/drutopia/"
drupal_composer_dependencies: []
# Set this to 'true' and 'build_makefile', 'build_composer' to 'false' if you
# are using Composer's create-project as a site deployment strategy.
drupal_build_composer_project: false
drupal_composer_project_package: "drupal-composer/drupal-project:8.x-dev"
drupal_composer_project_options: "--prefer-dist --stability dev --no-interaction"
# Set this to 'false' if you don't need to install drupal (using the drupal_*
# settings below), but instead copy down a database (e.g. using drush sql-sync).
drupal_install_site: false
# Required Drupal settings.
drupal_core_path: "{{ drupal_composer_install_dir }}/web"
drupal_core_owner: "{{ drupalvm_user }}"
drupal_db_user: drupal
drupal_db_password: drupal
drupal_db_name: drupal
drupal_db_host: localhost
# Settings for installing a Drupal site if 'drupal_install_site:' is 'true'.
drupal_major_version: 8
drupal_domain: "{{ vagrant_hostname }}"
drupal_site_name: "Drutopia"
drupal_install_profile: drutopia
drupal_enable_modules: [ ]
drupal_account_name: admin
drupal_account_pass: admin
drupal_account_email: admin@drutopia.org
# Additional arguments or options to pass to `drush site-install`.
drupal_site_install_extra_args: []
# Cron jobs are added to the vagrant user's crontab. Keys include name
# (required), minute, hour, day, weekday, month, job (required), and state.
drupalvm_cron_jobs: []
# Drupal VM automatically creates a drush alias file in your ~/.drush folder if
# this variable is 'true'.
configure_drush_aliases: true
drush_aliases_host_template: "templates/drupalvm.aliases.drushrc.php.j2"
drush_aliases_guest_template: "templates/drupalvm-local.aliases.drushrc.php.j2"
# Apache VirtualHosts. Add one for each site you are running inside the VM. For
# multisite deployments, you can point multiple servernames at one documentroot.
# View the geerlingguy.apache Ansible Role README for more options.
apache_vhosts:
- servername: "{{ drupal_domain }}"
serveralias: "www.{{ drupal_domain }}"
documentroot: "{{ drupal_core_path }}"
extra_parameters: "{{ apache_vhost_php_fpm_parameters }}"
- servername: "adminer.{{ vagrant_hostname }}"
documentroot: "{{ adminer_install_dir }}"
extra_parameters: "{{ apache_vhost_php_fpm_parameters }}"
- servername: "xhprof.{{ vagrant_hostname }}"
documentroot: "{{ php_xhprof_html_dir }}"
extra_parameters: "{{ apache_vhost_php_fpm_parameters }}"
- servername: "pimpmylog.{{ vagrant_hostname }}"
documentroot: "{{ pimpmylog_install_dir }}"
extra_parameters: "{{ apache_vhost_php_fpm_parameters }}"
- servername: "{{ vagrant_ip }}"
serveralias: "dashboard.{{ vagrant_hostname }}"
documentroot: "{{ dashboard_install_dir }}"
extra_parameters: "{{ apache_vhost_php_fpm_parameters }}"
apache_mods_enabled:
- expires.load
- headers.load
- ssl.load
- rewrite.load
- proxy.load
- proxy_fcgi.load
# MySQL databases and users.
mysql_databases:
- name: "{{ drupal_db_name }}"
encoding: utf8mb4
collation: utf8mb4_general_ci
mysql_users:
- name: "{{ drupal_db_user }}"
host: "%"
password: "{{ drupal_db_password }}"
priv: "{{ drupal_db_name }}.*:ALL"
# Comment out any extra utilities you don't want to install. If you don't want
# to install *any* extras, set this value to an empty set, e.g. `[]`.
installed_extras:
- adminer
# - blackfire
# - drupalconsole
- drush
# - elasticsearch
# - java
- mailhog
# - memcached
# - newrelic
# - nodejs
- pimpmylog
# - redis
# - ruby
# - selenium
# - solr
# - tideways
# - upload-progress
- varnish
# - xdebug
# - xhprof # use `tideways` if you're installing PHP 7+
# Add any extra apt or yum packages you would like installed.
extra_packages:
- sassc
- sqlite
# You can configure almost anything else on the server in the rest of this file.
drush_version: "8.1.14"
extra_security_enabled: false
firewall_enabled: true
firewall_allowed_tcp_ports:
- "22"
- "25"
- "80"
- "81"
- "443"
- "4444"
- "8025"
- "8080"
- "8443"
- "8983"
- "9200"
firewall_log_dropped_packets: false
firewall_disable_firewalld: true
firewall_disable_ufw: true
# PHP Configuration. Currently-supported versions: 5.6, 7.0, 7.1, 7.2.
# See version-specific notes: http://docs.drupalvm.com/en/latest/configurations/php/
php_version: "7.1"
php_install_recommends: no
php_memory_limit: "192M"
php_display_errors: "On"
php_display_startup_errors: "On"
php_realpath_cache_size: "1024K"
php_sendmail_path: "/opt/mailhog/mhsendmail"
php_opcache_enabled_in_ini: true
php_opcache_memory_consumption: "192"
php_opcache_max_accelerated_files: 4096
php_max_input_vars: "4000"
# Run specified scripts before or after VM is provisioned. Use {{ playbook_dir }}
# to reference the provisioning/ folder in Drupal VM or {{ config_dir }} to
# reference the directory where your `config.yml` is.
pre_provision_scripts: []
post_provision_scripts: []
# - "{{ playbook_dir }}/../examples/scripts/configure-solr.sh"
# MySQL Configuration.
mysql_root_password: root
mysql_slow_query_log_enabled: true
mysql_slow_query_time: 2
mysql_wait_timeout: 300
adminer_install_filename: index.php
# Node.js configuration (if enabled above).
# Valid examples: "0.10", "0.12", "4.x", "5.x", "6.x".
nodejs_version: "6.x"
nodejs_npm_global_packages: []
nodejs_install_npm_user: "{{ drupalvm_user }}"
npm_config_prefix: "/home/{{ drupalvm_user }}/.npm-global"
# Ruby Configuration (if enabled above).
ruby_install_gems_user: "{{ drupalvm_user }}"
ruby_install_gems: []
# Varnish Configuration (if enabled above).
varnish_listen_port: "81"
varnish_default_vcl_template_path: templates/drupalvm.vcl.j2
varnish_default_backend_host: "127.0.0.1"
varnish_default_backend_port: "80"
# Pimp my Log settings.
pimpmylog_install_dir: /usr/share/php/pimpmylog
pimpmylog_grant_all_privs: true
# XDebug configuration. XDebug is disabled by default for better performance.
php_xdebug_default_enable: 0
php_xdebug_coverage_enable: 0
php_xdebug_cli_enable: 1
php_xdebug_remote_enable: 1
php_xdebug_remote_connect_back: 1
# Use PHPSTORM for PHPStorm, sublime.xdebug for Sublime Text.
php_xdebug_idekey: PHPSTORM
php_xdebug_max_nesting_level: 256
php_xdebug_remote_host: "{{ ansible_default_ipv4.gateway }}"
# Solr Configuration (if enabled above).
solr_version: "6.6.2"
solr_xms: "64M"
solr_xmx: "128M"
# Selenium configuration.
selenium_version: 2.53.0
# Docker configuration.
docker_container_name: drutopia-vm
docker_image_name: drutopia-vm
docker_image_path: ~/Downloads
# Other configuration.
dashboard_install_dir: /var/www/dashboard
known_hosts_path: ~/.ssh/known_hosts
hostname_configure: true
hostname_fqdn: "{{ vagrant_hostname }}"
ssh_home: "{{ drupal_core_path }}"
post_provision_tasks_dir: ../../provisioning/tasks/*.yml

View file

@ -0,0 +1 @@
DoNotUseThisFileForProduction!

View file

@ -0,0 +1,6 @@
---
- hosts: all
any_errors_fatal: True
roles:
- role: drupal
serial: 1

View file

@ -0,0 +1,4 @@
---
web_dir: "~/site"
db_name: drupal
db_user: drupal

View file

@ -0,0 +1,13 @@
---
config_import: true
db_user: "{{ vault_db_user }}"
db_pwd: "{{ vault_db_pwd }}"
db_name: username_test
server_hostname: username-test.drutopia.org
server_aliases:
- "username.drutopia.org"
ssl_cert_path: ""
ssl_key_path: ""
git_repo: git@gitlab.com:my-org/my-project.git
git_branch: master
web_dir: /home/username_test/site/

View file

@ -0,0 +1,8 @@
$ANSIBLE_VAULT;1.1;AES256
65396435663335626232313336633134313964393733646639666133303030666162646432346363
3330636563626464613233343566393734393932663064310a383936393165373632636434376331
65613562383332656166373230316638363333396438663337613731646566366636643866353738
6161646237616663350a313361373538613230333063306634306434323730313832636163616632
30326566383066653764316531643334613934623631376462376265313139613561353831353037
65343263393338353139666534323934323266383934316234366135386536333936366461363638
353437303436333633633564373762643237

View file

@ -0,0 +1,2 @@
[drupal]
test ansible_host=username-test.drutopia.org ansible_user=username_test

View file

@ -0,0 +1,4 @@
---
build_dir: "../../build"
theme_name: "octavio"
server_aliases: []

View file

@ -0,0 +1,74 @@
---
# If re-enabled, allow to fail when missing:
# - name: reclaim permission to settings.local.php
# file:
# path: "{{ build_dir }}/web/sites/default/settings.local.php"
# state: file
# mode: "0766"
# delegate_to: 127.0.0.1
# run_once: true
#
# - name: reclaim permission to settings folder
# file:
# path: "{{ build_dir }}/web/sites/default"
# state: directory
# mode: "0777"
# recurse: true
# delegate_to: 127.0.0.1
# run_once: true
- name: delete build directory
file:
path: "{{ build_dir }}"
state: absent
delegate_to: 127.0.0.1
run_once: true
- name: re-create build directory
file:
path: "{{ build_dir }}"
state: directory
delegate_to: 127.0.0.1
run_once: true
- name: checkout version {{ git_branch }}
git:
accept_hostkey: yes
clone: yes
depth: 1
dest: "{{ build_dir }}"
name: "{{ git_repo }}"
update: yes
version: "{{ git_branch }}"
delegate_to: 127.0.0.1
run_once: true
- name: set site directory permissions
file:
path: "{{ build_dir }}"
state: directory
mode: "0755"
delegate_to: 127.0.0.1
run_once: true
# - name: generate css
# Need correct theme path? Just use theme_name as shown?:
# command: sassc {{ build_dir }}/web/themes/custom/{{ theme_name }}/sass/styles.scss {{ build_dir }}/web/themes/custom/{{ theme_name }}/css/styles.css
# delegate_to: 127.0.0.1
# run_once: true
- name: create settings.local.php
template:
src: "settings.local.php.j2"
dest: "{{ build_dir }}/web/sites/default/settings.local.php"
mode: "0755"
delegate_to: 127.0.0.1
- name: install composer-managed items
composer:
command: install
no_dev: true
optimize_autoloader: true
working_dir: "{{ build_dir }}"
delegate_to: 127.0.0.1
run_once: true

View file

@ -0,0 +1,22 @@
- set_fact:
dest: "{{ ansible_user }}@{{ ansible_fqdn }}:{{ web_dir }}"
- name: ensure {{ web_dir }} exists
file:
path: "{{ web_dir }}"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: "0755"
# - name: sync migrate folder
# local_action: command rsync -rz --delete {{ build_dir }}/migrate/ {{ dest }}/migrate/
- name: sync vendor folder
local_action: command rsync -rz --delete --links {{ build_dir }}/vendor/ {{ dest }}/vendor/
- name: sync config folder
local_action: command rsync -rz --delete {{ build_dir }}/config/ {{ dest }}/config/
- name: sync web folder
local_action: command rsync -rz --delete --exclude sites/default/files {{ build_dir }}/web/ {{ dest }}/web/

View file

@ -0,0 +1,91 @@
---
- name: update database
shell: "../vendor/bin/drush updb -y"
args:
chdir: "{{ web_dir }}/web/"
tags: deploy
- name: config sync import
shell: "../vendor/bin/drush cim -y"
args:
chdir: "{{ web_dir }}/web/"
when: config_import
tags: deploy
- name: cache rebuild
shell: "../vendor/bin/drush cr all"
args:
chdir: "{{ web_dir }}/web/"
tags: deploy
# Internal deploy process (CI):
# Git checkout projectURI to /home/{user}/site/, allowing overwrite of:
# /web/themes/custom/[*.tpl|*.yml]
# /config
# "Build"? (e.g. sassc)
# Write correct settings.local
# (push/rsync from CI -> stage)
# [link to drutopia version]
# updb/cim/cr
#
# -> test - wipe config and import.
# -> stage/prod - compare configurations.
#
# Already configured via _hosting:
# apache.conf
# db (empty?)
# user acct/apache process/etc
# fpm pool
# php.user.ini
# ...email, logging, etc
#
#
# vendor:
# - composer install
# compile css:
# - sassc
#
# default: test
# SETTINGS_TARGET: copy localhost
#
# drupal (local):
# - vendor, settings
# - drush si
# - chmod u+w defaultdir
#
# build:
# - mk build
# - git ark installation
# - composer install -d build_dir --no_dev
# - settings
# - mk sass dir/file
#
# deploy_config:
# - rsync config
#
# deploy_web:
# - rsync web (excl default)
#
# deploy_vendor:
# - rsync vendor
#
# deploy:
# - config+vendor+web
# - drush updb
# - drush cim
# - drush cr
#
#
#
# namespace :test do
# desc "Run Behat tests."
# task :behat => [:vendor] do
# sh "./vendor/bin/behat --tags '~@javascript' --format pretty --out std --format junit --out reports"
# end
#
# desc "Run performance tests."
# task :performance => [:vendor] do
# sh "./vendor/bin/phpunit --bootstrap ./vendor/autoload.php --log-junit reports/performance.xml tests/"
# end
# end
#

View file

@ -0,0 +1,7 @@
---
- include: build.yml
tags: build
- include: deploy.yml
tags: deploy
- include: drupal.yml
tags: deploy

View file

@ -0,0 +1,29 @@
<?php
/**
* @file
* Settings for the production environment.
*/
$databases['default']['default'] = array(
'driver' => 'mysql',
'database' => '{{ db_name }}',
'username' => '{{ db_user }}',
'password' => '{{ db_pwd }}',
'host' => '{{ db_host | default("localhost") }}',
'prefix' => '',
);
$settings['trusted_host_patterns'] = array(
'^{{ server_hostname | regex_replace('(\.)', '\\\.') }}$'
{% for host in server_aliases %}
,'^{{ host | regex_replace('\.', '\\\.') }}$'
{% endfor %}
);
{% if 'dev' in group_names %}
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
{% endif %}
$config_directories[CONFIG_SYNC_DIRECTORY] = '{{ config_dir | default("../config/sync/") }}';

View file

@ -0,0 +1,7 @@
---
- name: Grant vagrant access to logs
user:
name: vagrant
groups: adm
append: True
become: yes

View file

@ -0,0 +1,65 @@
---
- name: Run composer install.
command: "composer install"
args:
chdir: "{{ drupal_composer_install_dir }}"
- name: Check if site is already installed.
command: "{{ drupal_composer_install_dir }}/vendor/bin/drush --root={{ drupal_composer_install_dir }}/web/ status bootstrap"
args:
chdir: "{{ drupal_composer_install_dir }}/web"
register: drupal_site_installed
failed_when: "drupal_site_installed.stdout is undefined"
changed_when: false
become: no
# - name: Ensure /etc/drush folder exists
# file:
# name: /etc/drush
# state: directory
# group: root
# owner: root
# mode: 0755
# become: yes
#
# - name: Install drushrc.php
# copy:
# src: drushrc.php
# dest: /etc/drush/drushrc.php
# owner: root
# group: root
# mode: 0755
# backup: no
# become: yes
# - name: Add RewriteMap to vhost.conf
# lineinfile:
# path: /etc/apache2/sites-enabled/vhosts.conf
# line: "RewriteMap legacy \"txt:{{ web_root}}/redirect/legacy.txt\""
# insertafter: "DocumentRoot \"{{ web_root }}/web\""
# become: yes
- name: Install Drupal with drush.
command: >
{{ drupal_composer_install_dir }}/vendor/bin/drush site-install -y
--root={{ drupal_composer_install_dir }}/web
--site-name={{ drupal_site_name }}
--account-name={{ drupal_account_name }}
--account-pass={{ drupal_account_pass }}
--site-mail={{ drupal_account_email }}
args:
chdir: "{{ drupal_composer_install_dir }}/web"
become: no
when: "force_reinstall|default(false) or 'Drupal bootstrap' not in drupal_site_installed.stdout"
- name: Run sass
command: sassc sass/styles.scss css/styles.css
args:
chdir: "{{ drupal_composer_install_dir }}/web/themes/{{ theme }}/"
when: theme != ""
# - name: Ensure ansible is installed
# apt:
# name: ansible
# state: latest
# become: yes