well this works at any rate
This commit is contained in:
commit
0b0fd447f2
1 changed files with 84 additions and 0 deletions
84
playbook.yml
Normal file
84
playbook.yml
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
---
|
||||||
|
- name: Upgrade FoundKey
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
vars:
|
||||||
|
user: misskey
|
||||||
|
service: misskey
|
||||||
|
source_repository: /var/lib/misskey/FoundKey-0x7f
|
||||||
|
deploys_root: /var/lib/misskey/deploys
|
||||||
|
config_yml: /var/lib/misskey/default.yml
|
||||||
|
tasks:
|
||||||
|
- name: Generate deploy dir name
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
deploy_dir: "{{ deploys_root }}/{{ ansible_date_time.iso8601_basic_short }}"
|
||||||
|
run_once: true
|
||||||
|
- name: Print the generated deployment name
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: deploy_dir
|
||||||
|
run_once: true
|
||||||
|
- name: Build
|
||||||
|
become: true
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
environment:
|
||||||
|
NODE_ENV: production
|
||||||
|
block:
|
||||||
|
- name: Create deployment directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ deploy_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
recurse: true
|
||||||
|
- name: Clone source repository
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: "{{ source_repository }}"
|
||||||
|
dest: "{{ deploy_dir }}"
|
||||||
|
single_branch: true
|
||||||
|
- name: Link configuration in
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: "{{ deploy_dir }}/.config/default.yml"
|
||||||
|
src: "{{ config_yml }}"
|
||||||
|
state: link
|
||||||
|
- name: Reflink copy previous node_modules
|
||||||
|
ansible.builtin.command: cp -r --reflink "{{ deploys_root }}/current/node_modules" "{{ deploy_dir }}/node_modules"
|
||||||
|
args:
|
||||||
|
creates: "{{ deploy_dir }}/node_modules"
|
||||||
|
- name: Install Yarn dependencies
|
||||||
|
ansible.builtin.command: yarn install
|
||||||
|
changed_when: true
|
||||||
|
args:
|
||||||
|
chdir: "{{ deploy_dir }}"
|
||||||
|
- name: Build FoundKey
|
||||||
|
ansible.builtin.command: yarn build
|
||||||
|
changed_when: true
|
||||||
|
args:
|
||||||
|
chdir: "{{ deploy_dir }}"
|
||||||
|
- name: Deploy
|
||||||
|
block:
|
||||||
|
- name: Note down previous deploy
|
||||||
|
become: true
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
ansible.builtin.command: readlink "{{ deploys_root }}/current"
|
||||||
|
changed_when: true
|
||||||
|
register: previous_shell
|
||||||
|
- name: Link previous deploy
|
||||||
|
become: true
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: "{{ deploys_root }}/previous"
|
||||||
|
src: "{{ previous_shell.stdout }}"
|
||||||
|
state: link
|
||||||
|
force: true
|
||||||
|
- name: Link new deploy
|
||||||
|
become: true
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: "{{ deploys_root }}/current"
|
||||||
|
src: "{{ deploy_dir }}"
|
||||||
|
state: link
|
||||||
|
force: true
|
||||||
|
- name: Restart systemd service
|
||||||
|
become: true
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "{{ service }}"
|
||||||
|
state: restarted
|
Loading…
Reference in a new issue