Created
September 19, 2018 03:50
-
-
Save ctrlaltdylan/fffd7038d1ca9afe533083c932dc828c to your computer and use it in GitHub Desktop.
Deploying Wordpress with Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ansible-playbook playbook.yml -i hosts.yml -u ubuntu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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