Created
August 26, 2018 21:05
-
-
Save pgrm/d24be85de94647b1183c2f93afe5446e to your computer and use it in GitHub Desktop.
Ansible playbook to set up a new ghost blog and update the versions
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
# BEFORE UPDATING, export data from https://YOUR_BLOG/ghost/#/settings/labs | |
# (PLACEHOLDERS are defined in CAPS_LOCK - replace them with values which make sense to you.) | |
--- | |
- hosts: HOSTS | |
vars: | |
ghost_version: "2.0.3" | |
ghost_image: "ghost:{{ ghost_version }}-alpine" | |
ghost_root: "/docker/mounts/GHOST_BLOG" | |
archive_root: "/home/USER/archives/GHOST_BLOG" | |
tasks: | |
- name: Create ghost root folder folder | |
file: | |
path: "{{ ghost_root }}" | |
state: directory | |
owner: USER | |
group: USER | |
- name: Create archive folder | |
file: | |
path: "{{ archive_root }}" | |
state: directory | |
owner: USER | |
group: USER | |
- name: Backup ghost root folder | |
command: cp -r "{{ ghost_root }}" "{{ archive_root }}/ghost_backup_{{ '%Y-%m-%dT%H%M%S' | strftime }}" | |
- name: pull latest image | |
docker_image: | |
name: "{{ ghost_image }}" | |
- name: start ghost blog | |
docker_container: | |
name: GHOST_BLOG | |
image: "{{ ghost_image }}" | |
state: started | |
restart: yes | |
restart_policy: always | |
ports: | |
- "127.0.0.1:2370:2368" | |
volumes: | |
- "{{ ghost_root }}:/var/lib/ghost/content" | |
env: | |
url: https://YOUR_BLOG | |
NODE_ENV: production | |
# This is needed if you want to have an nginx reverse proxy for your blog. | |
- name: upload nginx configuration | |
copy: | |
src: ./nginx/GHOST_BLOG | |
dest: /etc/nginx/sites-enabled/GHOST_BLOG | |
become: true | |
- name: reload nginx service | |
service: name=nginx state=reloaded | |
become: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment