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,18 @@
---
- name: Detect if AppArmor is working.
command: service apparmor status
register: apparmor_status
failed_when: false
changed_when: false
- name: Ensure MySQL AppArmor profile is disabled (for slow query log).
file:
path: /etc/apparmor.d/disable/usr.sbin.mysqld
src: /etc/apparmor.d/usr.sbin.mysqld
state: link
register: mysql_apparmor
when: "mysql_slow_query_log_enabled and apparmor_status.rc == 0"
- name: Restart the AppArmor if necessary.
service: name=apparmor state=restarted
when: mysql_apparmor.changed

View file

@ -0,0 +1,5 @@
---
- name: nginx_hosts shim
set_fact:
nginx_vhosts: "{{ nginx_hosts }}"
when: nginx_hosts is defined

View file

@ -0,0 +1,16 @@
---
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"
- name: Define config_dir.
set_fact:
config_dir: "{{ playbook_dir }}/.."
when: config_dir is not defined
- name: Include optional configuration files.
include_vars: "{{ item }}"
with_fileglob:
- "{{ config_dir }}/config.yml"
- "{{ config_dir }}/secrets.yml"
- "{{ config_dir }}/{{ lookup('env', 'DRUPALVM_ENV')|default(drupalvm_env, true)|default(ansible_env.DRUPALVM_ENV)|default(omit) }}.config.yml"
- "{{ config_dir }}/local.config.yml"

View file

@ -0,0 +1,13 @@
---
- name: Ensure configured cron jobs exist in user account's crontab.
cron:
name: "{{ item.name }}"
minute: "{{ item.minute | default('*') }}"
hour: "{{ item.hour | default('*') }}"
day: "{{ item.day | default('*') }}"
weekday: "{{ item.weekday | default('*') }}"
month: "{{ item.month | default('*') }}"
job: "{{ item.job }}"
state: "{{ item.state | default('present') }}"
with_items: "{{ drupalvm_cron_jobs|default([]) }}"
become: no

View file

@ -0,0 +1,18 @@
---
- name: Ensure the dashboard directory exists.
file:
path: "{{ dashboard_install_dir }}"
state: directory
mode: 0755
- name: Copy dashboard page into place.
template:
src: ../templates/dashboard.html.j2
dest: "{{ dashboard_install_dir }}/index.html"
mode: 0644
- name: Copy phpinfo file into place.
copy:
src: ../templates/server-info.php.j2
dest: "{{ dashboard_install_dir }}/server-info.php"
mode: 0644

View file

@ -0,0 +1,45 @@
---
- name: Check if local Drush configuration folder exists.
stat:
path: ~/.drush
register: local_drush_config_folder
delegate_to: 127.0.0.1
become: no
when: configure_drush_aliases
- name: Create Drush configuration folder if it doesn't exist.
file:
path: ~/.drush
state: directory
delegate_to: 127.0.0.1
become: no
when: configure_drush_aliases and (local_drush_config_folder.stat.exists == false)
# Note that this doesn't work for Windows, since Ansible's running in the VM.
- name: Configure host machine drush aliases.
template:
src: "{{ drush_aliases_host_template }}"
dest: "~/.drush/{{ vagrant_machine_name }}.aliases.drushrc.php"
delegate_to: 127.0.0.1
become: no
when: configure_drush_aliases
- name: Ensure drush directory exists for vagrant user inside VM.
file: 'path="~/.drush" state=directory'
become: no
- name: Configure drush aliases for vagrant user inside VM.
template:
src: "{{ drush_aliases_guest_template }}"
dest: "~/.drush/{{ vagrant_machine_name }}.aliases.drushrc.php"
become: no
when: configure_drush_aliases
- name: Ensure drush directory exists for root user inside VM.
file: 'path="~/.drush" state=directory'
- name: Configure drush aliases for root user inside VM.
template:
src: "{{ drush_aliases_guest_template }}"
dest: "~/.drush/{{ vagrant_machine_name }}.aliases.drushrc.php"
when: configure_drush_aliases

View file

@ -0,0 +1,10 @@
---
- name: Install extra apt packages (if any are configured).
apt: "name={{ item }} state=installed"
with_items: "{{ extra_packages | list }}"
when: ansible_os_family == 'Debian' and extra_packages | length
- name: Install extra yum packages (if any are configured).
yum: "name={{ item }} state=installed"
with_items: "{{ extra_packages | list }}"
when: ansible_os_family == 'RedHat' and extra_packages | length

View file

@ -0,0 +1,26 @@
---
- name: Update apt cache if needed.
apt: update_cache=yes cache_valid_time=86400
- name: Install required dependencies.
apt: "name={{ item }} state=installed"
with_items:
- curl
- python-apt
- python-pycurl
- sudo
- unzip
- make
# Ubuntu-specific tasks.
- name: Add repository for Apache 2.4.9+ (Ubuntu 12/14).
apt_repository: repo='ppa:ondrej/apache2'
when: >
(ansible_distribution_release == "precise" or ansible_distribution_release == "trusty") and
ansible_distribution == "Ubuntu"
- name: Define php_xhprof_html_dir.
set_fact:
php_xhprof_html_dir: "/usr/share/php/xhprof_html"
when: php_xhprof_html_dir is not defined
tags: ['webserver']

View file

@ -0,0 +1,19 @@
---
- name: Install required dependencies.
yum: "name={{ item }} state=installed"
with_items:
- curl
- python-pycurl
- unzip
- make
- gcc
- name: Enable remi repo for MySQL.
set_fact: mysql_enablerepo="remi"
when: mysql_enablerepo is not defined or mysql_enablerepo == ""
- name: Define php_xhprof_html_dir.
set_fact:
php_xhprof_html_dir: "/usr/share/pear/xhprof_html"
when: php_xhprof_html_dir is not defined
tags: ['webserver']

View file

@ -0,0 +1,13 @@
---
- name: Set the PHP webserver daemon correctly when nginx is in use.
set_fact:
php_webserver_daemon: nginx
when: drupalvm_webserver == 'nginx'
tags: ['webserver', 'database', 'php']
- name: Ensure PHP version -specific workspace directory exists.
file:
path: "/root/php{{ php_version }}"
state: directory
mode: 0775
tags: ['php', 'xdebug']

View file

@ -0,0 +1,42 @@
---
- name: Do not accept locale environment variables passed over SSH.
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^AcceptEnv LANG"
state: absent
validate: "/usr/sbin/sshd -T -f %s"
- name: Allow client to pass PHP and XDEBUG environment variables over SSH.
lineinfile:
dest: /etc/ssh/sshd_config
line: "AcceptEnv {{ item }}"
validate: "/usr/sbin/sshd -T -f %s"
with_items:
- PHP_IDE_CONFIG
- XDEBUG_CONFIG
- PHP_OPTIONS
when: '"xdebug" in installed_extras'
- name: Check if local known_hosts file is present.
stat: "path={{ known_hosts_path | default('~/.ssh/known_hosts') }}"
register: known_hosts_file
connection: local
become: no
- name: Copy known_hosts file from host into Drupal VM.
copy:
src: "{{ known_hosts_path | default('~/.ssh/known_hosts') }}"
dest: ~/.ssh/known_hosts
mode: 0644
become: no
when: known_hosts_file.stat.exists
- name: Set SSH home directory.
lineinfile:
dest: "/home/{{ drupalvm_user }}/.bashrc"
state: present
create: yes
regexp: "^SSH_HOME="
line: "SSH_HOME={{ ssh_home }} && [ -e $SSH_HOME ] && cd $SSH_HOME"
become: no
when: ssh_home is defined