Deploying Drupal 8 using Ansible Playbook: Part 1

Prerequisites

Getting Started with Ansible

aliyun@ubuntu:~$ ansible --version
ansible 2.5.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/aliyun/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
mkdir ~/drupal-ansible
cd ~/drupal-ansible
nano ansible.cfg
[defaults]
inventory = hosts
host_key_checking = false
private_key_file = ~/.ssh/aliyun.pem
nano hosts
web-server  ansible_ssh_host=192.168.0.1 ansible_ssh_user=root
db-server ansible_ssh_host=192.168.0.2 ansible_ssh_user=root
[all:vars]
ansible_python_interpreter=/usr/bin/python3
aliyun@ubuntu:~/drupal-ansible$ ansible all -m ping
db-server | SUCCESS => {
"changed": false,
"ping": "pong"
}
web-server | SUCCESS => {
"changed": false,
"ping": "pong"
}
cd ~/drupal-ansible
nano playbook.yaml
---
- hosts: all
gather_facts: true
tasks:
- name: update and upgrade system packages
apt:
upgrade: yes
update_cache: yes
- hosts: db-server
roles:
- mariadb
- hosts: web-server
become: true
roles:
- php
- drupal
- nginx

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store