Skip to content

Instantly share code, notes, and snippets.

@ctrlaltdylan
Created September 19, 2018 03:50
Show Gist options
  • Save ctrlaltdylan/fffd7038d1ca9afe533083c932dc828c to your computer and use it in GitHub Desktop.
Save ctrlaltdylan/fffd7038d1ca9afe533083c932dc828c to your computer and use it in GitHub Desktop.
Deploying Wordpress with Ansible
ansible-playbook playbook.yml -i hosts.yml -u ubuntu
all:
hosts:
wordpress:
ansible_host: yoursite.com # your server's IP address or domain
ansible_private_key_file: # path to your identity file to authenticate, like ~/.ssh/id_rsa.pem
---
- hosts: wordpress # from the 'hosts' definition in hosts.yml
tasks:
# deploys all new content except for user uploaded media
- name: 'Deploy new content'
synchronize:
src: ./
dest: /home/ubuntu/current/ # change this to your remote hosts's IP address
recursive: yes
delete: yes
rsync_opts: # exclude sensitive or too-big directories
- '--exclude=wp-content/uploads'
- '--exclude=.env'
become: yes
- name: 'Change owner'
file:
path: /home/ubuntu/current
state: directory
owner: ubuntu # change the recently deployed files to your server/group of choice
group: ubuntu
recurse: yes
become: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment