sitepilot/stack-nginx

Ansible playbooks for provisioning web servers optimized for WordPress and Laravel.

Installs: 232

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 2

Forks: 0

Open Issues: 0

Language:Jinja

v1.1.16 2022-07-13 09:12 UTC

README

Ansible playbooks for provisioning optimized web servers for WordPress and Laravel. These playbooks are used by Autopilot (our cloud server control panel) and are perfect for:

  • Local development environments.
  • High-performance production servers (with caching).

Requirements

  • Ansible
  • Ubuntu 20.04 LTS (Desktop/Server)

Inventory

Before you can provision a resource you've to provision a server first. Add your inventory to the hosts folder and provision a server or group using the following command:

Example:

# Provision a server (or group)
ansible-playbook server.yml -e host=<server>

Resources

Resource playbooks use variables defined in a resource file, add your resources to the resources folder and reference the file while running a playbook. You can find resource examples in the tests folder.

# Example
ansible-playbook site.yml -e @resources/sites/my-site.yml

Available resource variables are defined in the defaults folder of a resource role and validated in the first assert task of each tasks file.

Site

# Provision a site
ansible-playbook site.yml -e @resources/sites/my-site.yml

# Backup a site
ansible-playbook site.yml -e @resources/sites/my-site.yml -t backup

# List site backups
ansible-playbook site.yml -e @resources/sites/my-site.yml -t backup/list

# Restore site backup
ansible-playbook site.yml -e @resources/sites/my-site.yml -t backup/restore

# Destroy site backup
ansible-playbook site.yml -e @resources/sites/my-site.yml -t backup/destroy

# Destroy a site
ansible-playbook site.yml -e @resources/sites/my-site.yml -t destroy

Database

# Provision a database
ansible-playbook database.yml -e @resources/databases/my-database.yml

# Backup a database
ansible-playbook database.yml -e @resources/databases/my-database.yml -t backup

# List database backups
ansible-playbook database.yml -e @resources/databases/my-database.yml -t backup/list

# Restore database backup
ansible-playbook database.yml -e @resources/databases/my-database.yml -t backup/restore

# Destroy database backup
ansible-playbook database.yml -e @resources/databases/my-database.yml -t backup/destroy

# Destroy a database
ansible-playbook database.yml -e @resources/databases/my-database.yml -t destroy

User

# Provision a user
ansible-playbook user.yml -e @resources/users/my-user.yml

# Destroy a user
ansible-playbook user.yml -e @resources/users/my-user.yml -t destroy

Web Apps

  • Health check: https://{{ site_domain }}/-/ping/
  • phpMyAdmin: https://{{ site_domain }}/-/phpmyadmin/
  • Mailhog: https://{{ site_domain }}/-/mailhog/
  • Node Exporter: https://{{ site_domain }}/-/monitor/

Filesystem

  • Vhosts: /usr/local/openresty/nginx/conf/sites-enabled
  • PHP-FPM pools: /etc/php/{{ php_version }}/fpm/pool.d
  • MariaDB data: /opt/sitepilot/stack/mariadb/data

Site Files

  • Public path: /opt/sitepilot/sites/{{ site_name }}/files
  • Logs path: /opt/sitepilot/sites/{{ site_name }}/logs
  • Cache path: /opt/sitepilot/sites/{{ site_name }}/.cache
  • Config path: /opt/sitepilot/sites/{{ site_name }}/.config
  • User home path: /opt/sitepilot/sites/{{ site_name }}/home

Cache Purge

Send a PURGE request to the URL you would like to purge:

# Purge site cache
curl -X PURGE https://{{ site_domain }}/

# Purge a single post
curl -X PURGE https://{{ site_domain }}/hello-world/

Author

These playbooks are developed and maintained by Nick Jansen.