Skip to content

Instantly share code, notes, and snippets.

@pkoziol
Created February 1, 2018 19:00
Show Gist options
  • Save pkoziol/a95bfa3a3266953295ab442efde3c6da to your computer and use it in GitHub Desktop.
Save pkoziol/a95bfa3a3266953295ab442efde3c6da to your computer and use it in GitHub Desktop.
Ansible playbook to upgrade https://github.com/firefly-iii/firefly-iii to the new version.
---
- hosts: vps
become: yes
become_user: firefly-iii
vars:
ff_old_version: 4.6.13
ff_new_version: 4.7.0
tasks:
- name: Check if Firefly III {{ ff_new_version }} directory exists
stat:
path: /home/firefly-iii/firefly-iii-{{ ff_new_version }}
register: ff_project_directory
- name: Create Firefly III {{ ff_new_version }} project
composer:
command: create-project
arguments: grumpydictator/firefly-iii firefly-iii-{{ ff_new_version }} {{ ff_new_version }}
working_dir: /home/firefly-iii/
no_dev: yes
prefer_dist: yes
when: ff_project_directory.stat.exists == False
- name: Copy .env file
command: >
cp /home/firefly-iii/firefly-iii-{{ ff_old_version }}/.env
/home/firefly-iii/firefly-iii-{{ ff_new_version }}/.env
- name: Copy storage/upload/ directory
command: >
cp -r /home/firefly-iii/firefly-iii-{{ ff_old_version }}/storage/upload/
/home/firefly-iii/firefly-iii-{{ ff_new_version }}/storage/upload/
- name: Copy storage/export/ directory
command: >
cp -r /home/firefly-iii/firefly-iii-{{ ff_old_version }}/storage/export/
/home/firefly-iii/firefly-iii-{{ ff_new_version }}/storage/export/
- name: Cleanup bootstrap/cache/ directory
file:
state: "{{ item }}"
path: /home/firefly-iii/firefly-iii-{{ ff_new_version }}/bootstrap/cache/
with_items:
- absent
- directory
- name: Run artisan migrate
command: php71 artisan migrate --env=production --no-interaction --force
args:
chdir: /home/firefly-iii/firefly-iii-{{ ff_new_version }}/
- name: Run artisan cache:clear
command: php71 artisan cache:clear --no-interaction
args:
chdir: /home/firefly-iii/firefly-iii-{{ ff_new_version }}/
- name: Run artisan firefly:upgrade-database
command: php71 artisan firefly:upgrade-database --no-interaction
args:
chdir: /home/firefly-iii/firefly-iii-{{ ff_new_version }}/
- name: Update symbolic link
file:
src: /home/firefly-iii/firefly-iii-{{ ff_new_version }}
dest: /home/firefly-iii/firefly-iii.example.com
state: link
- name: Update permissions of files in storage/ directory
command: find /home/firefly-iii/firefly-iii.example.com/storage/ -type f -exec chmod u=rw,g=rw {} \;
- name: Update permissions of directories in storage/ directory
command: find /home/firefly-iii/firefly-iii.example.com/storage/ -type d -exec chmod u=rwx,g=rwxs {} \;
- name: Update owner of storage/ directory
command: chown -R php71:firefly-iii /home/firefly-iii/firefly-iii.example.com/storage/
become: yes
become_user: root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment