• Stars
    star
    105
  • Rank 317,976 (Top 7 %)
  • Language Jinja
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Drupal on Docker on a Raspberry Pi. Pi Dramble's little brother.

Drupal Pi

CI

Drupal on Docker on a Raspberry Pi

Drupal 8 on a Raspberry Pi

This project is an offshoot of the Rasbperry Pi Dramble project, which helps install Drupal on a cluster ('Bramble') of Raspberry Pi computers.

This playbook/project makes setting up Drupal on a single Raspberry Pi a very easy/simple operation using Nginx and Docker Compose.

Set up the Raspberry Pi

Drupal requires as good a Raspberry Pi as you can afford. While Drupal will run okay on any Raspberry Pi, it's best to use a model 2 B or later (newer models have a snappy four-core processor and at least 1GB RAM).

Once you have your Raspberry Pi and a good microSD card (the fastest/best one you can getโ€”see microSD Card Benchmarks!), you will need to do a few things to set up the Raspberry Pi and get it ready to run Drupal.

Set up on Raspberry Pi with Raspbian / GUI

These directions assume you're working directly on your Raspberry Pi, running Raspbian, with a keyboard and monitor attached:

  1. Download the latest 'Raspbian' image from the Raspberry Pi Downloads pageโ€ .
  2. Follow the image installation guide to transfer the image to your microSD card:
    1. Unmount the microSD card: diskutil unmountDisk /dev/disk2
    2. Write the image to the microSD card: pv yyyy-mm-dd-raspbian-stretch.img | sudo dd bs=1m of=/dev/rdisk2
  3. Once Raspbian is loaded on the card, insert the card in your Pi, and plug in your Pi to boot it up.
  4. Boot up the Raspberry Pi. Once booted, open the "Raspberry Pi Configuration" tool in Menu > Preferences.
    1. Change the pi user account password.
    2. Click OK, then reboot the Raspberry Pi.
  5. Once rebooted, connect the Pi to your local network either via WiFi or wired ethernet.
  6. Open the Terminal application (in the launcher or in Menu > Accessories > Terminal).
  7. Install Ansible: sudo apt-get update && sudo apt-get install -y python3-dev python3-pip libyaml-dev libffi-dev && sudo pip3 install ansible
  8. Test the Ansible installation: ansible --version (should output the Ansible version).

โ€  If you plan on using your Pi as a headless Drupal server, you don't need all the extra software included with the default Raspbian image. I recommend you use the official 'Raspbian Lite' image instead; see the next section.

Set up on Raspberry Pi with Raspbian Lite / CLI

These directions assume you're working either directly on your Raspberry Pi, running Raspbian Lite, or remotely logged into the Pi via SSH:

  1. Download the latest 'Raspbian Lite' image from the Raspberry Pi Downloads pageโ€ .
  2. Follow the image installation guide to transfer the image to your microSD card:
    1. Unmount the microSD card: diskutil unmountDisk /dev/disk2
    2. Write the image to the microSD card: pv yyyy-mm-dd-raspbian-stretch-lite.img | sudo dd bs=1m of=/dev/rdisk2
    3. Ensure SSH is enabled by adding an 'ssh' file to the boot volume: touch /Volumes/boot/ssh
    4. If you need to enable WiFi headlessly, add a wpa_supplicant.conf file to the boot volume as well:
      1. Create the file: touch /Volumes/boot/wpa_supplicant.conf
      2. Add the contents:
        ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
        update_config=1
        country=US
        
        network={
            ssid="your-network-name"
            psk="your-network-password"
            key_mgmt=WPA-PSK
        }
        
  3. Once Raspbian Lite is loaded on the card, insert the card in your Pi, and plug in your Pi to boot it up.
  4. Boot up the Raspberry Pi. Once booted, log in (default username is pi and default password is raspberry), and run sudo raspi-config.
    1. Set a better password for the Pi's default user account.
    2. Scroll down to 'Finished', hit return, and reboot the Raspberry Pi.
  5. Once rebooted, connect the Pi to your local network either via WiFi or wired ethernet.
  6. Log back in (either on the Pi directly or via SSH).
  7. Install Ansible: sudo apt-get update && sudo apt-get install -y python3-dev python3-pip libyaml-dev libffi-dev git && sudo pip3 install ansible
  8. Test the Ansible installation: ansible --version (should output the Ansible version).

Install LEMP software stack and Drupal with Ansible and Docker

Installing using the Raspberry Pi

You need to download this repository to the Pi and run the included playbook to install and configure everything.

  1. Clone the drupal-pi project: git clone https://github.com/geerlingguy/drupal-pi.git && cd drupal-pi
  2. Copy example.inventory to inventory.
  3. (Optional) Create a config.yml and override any settings from default.config.yml as needed.
  4. Install required Ansible roles: ansible-galaxy install -r requirements.yml
  5. Run the Ansible playbook: ansible-playbook -c local main.yml

After a few minutes, the playbook should complete successfully, and you should have Drupal running on your Raspberry Pi, accessible via http://localhost/

To be able to access the site from other computers on your network (e.g. by accessing http://www.drupalpi.test/, add an entry to your local hosts file like [ip-of-raspberry-pi] www.drupalpi.test.

NOTE: For best security, you should create a config.yml file and at least override any password settings from the default.config.yml file (e.g. drupal_database_password).

Installing using another host with Ansible installed

You can run the Ansible playbook from another host (instead of from within the VMโ€”this also allows you to do everything without installing pip and ansible on the Raspberry Pi itself!).

  1. Change the inventory file to use the Pi's IP address instead of 127.0.0.1.
  2. Make sure you have your SSH private key configured for the pi account on the Pi (I use ssh-copy-id to copy my ID to the Pi).
  3. Install required Ansible roles: ansible-galaxy install -r requirements.yml
  4. Run the Ansible playbook: ansible-playbook main.yml

Note: If you have a headless Raspberry Pi and would like to find it's IP address, one way of doing so is to use a tool like Fing).

Advanced Usage

Adding your own Ansible tasks

If you need to add some additional automation, there is a concept of 'hook' files which will get called at different stages of the build if they are present (in the root directory of this project):

  • hook-pre-tasks.yml: Gets called in the pre_tasks section of the playbook before any Ansible roles or tasks are applied.
  • hook-tasks.yml: Gets called at the start of the tasks section of the playbook (after roles are applied).

One use of these hooks would be to do extra steps to deploy your own container and codebase, without having to use a private registry. See an example which I use to build and deploy one of my Drupal codebases: hook-tasks.yml example for Drupal for Kubernetes.

Updating your Pi (for future versions of Drupal Pi)

If you need to update Drupal Pi, do the following:

  1. cd into the project directory: cd /path/to/drupal-pi
  2. Pull the latest changes: git pull
  3. Update all required Ansible roles (and install new ones): sudo ansible-galaxy install -r requirements.yml --force
  4. Run the Ansible playbook: ansible-playbook -i inventory -c local main.yml

Note: Remove -c local if running from another host.

Resetting the Drupal Install

There is a reset.yml playbook included that will reset the environment so you can install a fresh copy of Drupal. To run the playbook, enter the following command in the same directory as this README:

ansible-playbook -i inventory -c local reset.yml

Note: Remove -c local if running from another host.

After it finishes resetting the environment, you can run the main.yml playbook again to rebuild the Drupal site.

Enabling Proxy Caching

The Drupal Pi includes a basic proxy cache configuration which uses Nginx to reverse proxy and cache all requests which do not include a Drupal session cookie. This can increase the speed of page delivery by 60x or more, meaning your little Pi could serve up more traffic than most home Internet uplinks could handle!

To enable Nginx's proxy cache, set the following value in your config.yml and run the main playbook:

nginx_proxy_cache: true

Using Drupal Pi as a load balancer for Pi Dramble

This project can also switch from running a site locally to being used as a load balancer for the Pi Dramble Cluster. All you have to do is set nginx_use_as_lb: true in your config.yml, make sure all the Pis which are responding to requests are in the nginx_lb_backends list, and run the playbook to redeploy the Nginx configuration.

Then point the domain you would normally point at the Pi Dramble cluster (e.g. cluster.pidramble.test) at the IP of the single Drupal Pi instead!

Author

This project was started in 2015 by Jeff Geerling, author of Ansible for DevOps.

More Repositories

1

ansible-for-devops

Ansible for DevOps examples.
Python
7,475
star
2

mac-dev-playbook

Mac setup and configuration via Ansible.
Shell
5,735
star
3

internet-pi

Raspberry Pi config for all things Internet.
Jinja
3,690
star
4

macos-virtualbox-vm

Instructions and script to help you create a VirtualBox VM running macOS.
Shell
2,519
star
5

ansible-vagrant-examples

Ansible examples using Vagrant to deploy to local VMs.
2,034
star
6

raspberry-pi-dramble

DEPRECATED - Raspberry Pi Kubernetes cluster that runs HA/HP Drupal 8
Shell
1,656
star
7

ansible-role-docker

Ansible Role - Docker
1,515
star
8

drupal-vm

A VM for Drupal development
Jinja
1,371
star
9

pi-webcam

Automation to configure a Raspberry Pi as a USB OTG webcam
1,322
star
10

internet-monitoring

Monitor your network and internet speed with Docker & Prometheus
1,237
star
11

raspberry-pi-pcie-devices

Raspberry Pi PCI Express device compatibility database
HTML
1,230
star
12

ansible-role-mysql

Ansible Role - MySQL
Jinja
988
star
13

ansible-role-jenkins

Ansible Role - Jenkins CI
Groovy
802
star
14

ansible-role-nginx

Ansible Role - Nginx
Jinja
774
star
15

ansible-role-security

Ansible Role - Security
Jinja
706
star
16

ansible-role-certbot

Ansible Role - Certbot (for Let's Encrypt)
Shell
698
star
17

ansible-role-gitlab

Ansible Role - GitLab
Jinja
653
star
18

packer-boxes

Jeff Geerling's Packer build configurations for Vagrant boxes.
Shell
635
star
19

ansible-for-kubernetes

Ansible and Kubernetes examples from Ansible for Kubernetes Book
Shell
612
star
20

my-backup-plan

How I back up all my data.
Shell
576
star
21

dotfiles

My configuration. Minimalist, but helps save a few thousand keystrokes a day.
Shell
540
star
22

ansible-role-firewall

Ansible Role - iptables Firewall configuration.
Shell
481
star
23

ansible-role-postgresql

Ansible Role - PostgreSQL
Jinja
478
star
24

kubernetes-101

Kubernetes 101 - by Jeff Geerling
HTML
477
star
25

ansible-role-php

Ansible Role - PHP
Jinja
468
star
26

ansible-role-kubernetes

Ansible Role - Kubernetes
Jinja
425
star
27

Ping

A PHP class to ping hosts.
PHP
415
star
28

ansible-role-apache

Ansible Role - Apache 2.x.
Jinja
392
star
29

ansible-role-nodejs

Ansible Role - Node.js
Jinja
386
star
30

turing-pi-cluster

DEPRECATED - Turing Pi cluster configuration for Raspberry Pi Compute Modules
Jinja
347
star
31

awx-container

Ansible Container project that manages the lifecycle of AWX on Docker.
297
star
32

ansible-role-java

Ansible Role - Java
Jinja
293
star
33

ansible-role-ntp

Ansible Role - NTP
Jinja
290
star
34

pi-timelapse

Time-lapse app for Raspberry Pi computers.
Python
278
star
35

temperature-monitor

Raspberry Pi-based home temperature monitoring network.
JavaScript
256
star
36

pi-cluster

Raspberry Pi Cluster automation
Shell
231
star
37

ansible-role-awx

DEPRECATED Ansible Role - AWX
230
star
38

ansible-role-homebrew

Ansible Role - Homebrew (MOVED to geerlingguy.mac collection)
Shell
228
star
39

ansible-role-redis

Ansible Role - Redis
Jinja
228
star
40

packer-centos-7

This build has been moved - see README.md
223
star
41

ansible-collection-mac

Collection of macOS automation tools for Ansible.
Shell
220
star
42

ansible-role-dotfiles

Ansible Role - Easy and flexible dotfile installation.
214
star
43

ansible-role-nfs

Ansible Role - NFS
Jinja
207
star
44

ansible-role-haproxy

Ansible Role - HAProxy
Jinja
194
star
45

ansible-role-git

Ansible Role - Git
188
star
46

ansible-role-repo-epel

Ansible Role - EPEL Repository for RHEL/CentOS
175
star
47

ansible-role-composer

Ansible Role - Composer PHP Dependency Manager
Jinja
175
star
48

ansible-role-pip

Ansible Role - Pip (for Python)
174
star
49

turing-pi-2-cluster

DEPRECATED - Turing Pi 2 Cluster
Jinja
174
star
50

ansible-role-logstash

Ansible Role - Logstash
Jinja
168
star
51

ansible-role-elasticsearch

Ansible Role - Elasticsearch
Jinja
167
star
52

pico-w-garage-door-sensor

Wireless garage door sensor for Home Assistant powered by Raspberry Pi Pico W
Python
166
star
53

drupal-for-kubernetes

Drupal Example Site for Kubernetes
PHP
149
star
54

ansible-role-filebeat

Ansible Role - Filebeat for ELK stack
Jinja
137
star
55

ansible-role-backup

Ansible Role - Backup for simple servers
Shell
135
star
56

ansible-role-ansible

Ansible Role - Ansible
130
star
57

airgradient-prometheus

AirGradient Prometheus exporter.
C++
116
star
58

ansible-role-kibana

Ansible Role - Kibana
Jinja
115
star
59

ansible-role-swap

Ansible Role - Swap
107
star
60

obs-task-list-overlay

An HTML and Node.js-based task list overlay for OBS.
JavaScript
105
star
61

ansible-role-glusterfs

Ansible Role - GlusterFS
104
star
62

ansible-role-raspberry-pi

Configures a Raspberry Pi (running Raspbian).
102
star
63

docker-centos7-ansible

CentOS 7 Docker container for Ansible playbook and role testing.
Dockerfile
101
star
64

packer-ubuntu-1804

This build has been moved - see README.md
101
star
65

ansible-role-solr

Ansible Role - Apache Solr
Shell
97
star
66

ansible-mastodon

Mastodon installation on a single server using Ansible.
Jinja
95
star
67

sbc-reviews

Jeff Geerling's SBC review data - Raspberry Pi, Radxa, Orange Pi, etc.
93
star
68

ansible-role-supervisor

Ansible Role - Supervisor
Shell
92
star
69

ansible-role-docker_arm

Ansible Role - Docker for ARM and Pi
91
star
70

ansible-requirements-updater

Update your requirements.yml with this grisly Ansible playbook.
90
star
71

ansible-role-php-versions

Ansible Role - PHP Versions
88
star
72

ansible-role-ruby

Ansible Role - Ruby
Shell
86
star
73

JJG-Ansible-Windows

[DEPRECATED] Windows shell provisioning script to bootstrap Ansible from within a Vagrant VM.
Shell
85
star
74

ansible-role-mas

Ansible Role - Mac App Store CLI (MOVED to geerlingguy.mac collection)
84
star
75

ansible-role-drupal

Ansible Role - Drupal
84
star
76

ansible-role-postfix

Ansible Role - Postfix
82
star
77

tower-operator

DEPRECATED: This project was moved and renamed to: https://github.com/ansible/awx-operator
Dockerfile
82
star
78

ansible-role-varnish

Ansible Role - Varnish HTTP accelerator
Jinja
82
star
79

packer-ubuntu-1404

DEPRECATED - Packer Example - Ubuntu 14.04 Vagrant Box using Ansible provisioner
Shell
82
star
80

pi4gpu

Raspberry Pi GPU Carrier Board
OpenSCAD
82
star
81

pi-camera

A Raspberry Pi Camera
Python
79
star
82

pi-router

Raspberry Pi-based OpenWRT router config for 4G/5G Waveshare Dual Ethernet board.
Dockerfile
79
star
83

packer-centos-6

This build has been moved - see README.md
79
star
84

docker-ubuntu1804-ansible

Ubuntu 18.04 LTS (Bionic) Docker container for Ansible playbook and role testing.
Dockerfile
78
star
85

top500-benchmark

Automated Top500 benchmark for clusters or single nodes.
Jinja
76
star
86

deskpi-super6c-cluster

DEPRECATED - DeskPi Super6c 6-node Raspberry Pi CM4 Cluster
76
star
87

docker-examples

There are many like it, but this one is mine.
Python
75
star
88

youtube-10k-pods

10,000 Kubernetes Pods for 10,000 Subscribers
74
star
89

docker-ubuntu2004-ansible

Ubuntu 20.04 LTS (Focal Fossa) Docker container for Ansible playbook and role testing.
Dockerfile
74
star
90

pi-bell-slapper

The King of Ding. Internet-connected Raspberry Pi-based notification bell.
OpenSCAD
74
star
91

baby-safe-temp

Safe temperature monitor for baby's room. Made for Raspberry Pi Pico.
Python
74
star
92

ansible-role-memcached

Ansible Role - Memcached
Jinja
68
star
93

ansible-role-node_exporter

Ansible role - Node exporter
Jinja
66
star
94

ansible-role-mailhog

Ansible Role - MailHog for catching and viewing emails
Shell
62
star
95

molecule-playbook-testing

This is an example from the Ansible 101 livestream
62
star
96

ansible-role-ssh-chroot-jail

Ansible Role - SSH chroot jail config
Shell
60
star
97

pi-nvr

Raspberry Pi NVR for home CCTV recording.
Dockerfile
58
star
98

Imap

Simple wrapper class for PHP's IMAP-related email functions.
PHP
57
star
99

Request

A simple PHP HTTP request class.
PHP
56
star
100

ansible-role-samba

Ansible Role - Samba
55
star