/drupal_ansible

A simple-ish way to set up your server for drupal and to be able to move from local system to your servers in cloud. Uses Ansible.

Primary LanguageShell

# Drupal Ansible with D8 recipe

This allows us to install / spin up a new D8 site. We are using the `deploy` user
to spin the sites up.

## Architecture

### Ansible Playbooks

The recipes consist of various files. At the root level, we have our main points
of interaction via playbooks (these files will mostly be left unchanged):

- install_python.yml -- Ansible requires a server to have python installed to
  work correctly. This file bypasses that check and installs python so the rest
  of the steps work.
- provision.yml -- Installs the necessary software on a server (nginx, mysql, etc)
- install-site.yml -- This will set up a new Drupal site based on a git repository with composer install
- deploy-site.yml -- This will deploy new code changes from a git repo for a drupal site.

### ```inventory``` File

We also have the inventory file. This file consists of servers along with their
groups. This file has been simplified so that we are just listing groups of
types of servers. Eventually, we will use this file to show how to run 'multiple'
hosts.

### ```group_vars``` directory

This section is very important only to explain what this section does. You will
not actually touch any files in this section.

- [all] = this directory contains variables that all servers will get. The
  vault.yml file contains ssh keys for your users.
- [web] = This directory contains variables that pertain to what gets set up on
  'web' servers. The vault.yml file contains the application db connection
  credentials.
- [db] = This directory contains variables that pertain to what gets set up on
  'db' servers. The vault.yml file sets up mysql users, databases, and
  permissions.

Servers get added to the inventory file and they pick up variables that are
defined in these groups. Each group directory has 2 files:

- vars.yml - These are variables that are publicly viewable in an editor.
- vault.yml - These are variables that get encrypted so they can be committed
  to git.

## Instructions to setting up a the ymls.

- Add the server to the inventory file. I recommend giving the server an aliased
  name
- Add the server to the appropriate group in the inventory file.
- Update the file with the appropriate variables (like the mysql database
  connection, etc).

## Instructions once the inventory and group_vars are set up.

### Step 1

#### Spin up new server with Ubuntu 16.04

### Step 2

LOCALLY: First install Ansible (brew install ansible is easiest)

#### Install ansible galaxy requirements

The repo already comes with them. However, if you want to replace them:

`ansible-galaxy install -r requirements.yml -p roles -f`

### Step 3

#### Run through the provisioning playbook and set up a server (Enter the vault pass on prompt)

ansible-playbook --ask-vault-pass -i inventory -u <ROOT_USER> install_python.yml
ansible-playbook --ask-vault-pass -i inventory -u <ROOT_USER> provision.yml

### Step 4

#### Run through the site playbook and set up a default site with the codebase (Enter the vault pass on prompt, along with your bitbucket username and password when prompted)

ansible-playbook --ask-vault-pass -i inventory -u <ROOT_USER> install-site.yml

### Step 5

#### Run through the deploy playbook and set up a proper deployment.

ansible-playbook --ask-vault-pass -i inventory -u <ROOT_USER> deploy-site.yml