1
0
Fork 0

feat: utility commands

This commit is contained in:
Michcio 2022-10-10 20:36:20 +02:00
parent 29d3fefa45
commit 7e08cff138
2 changed files with 57 additions and 1 deletions

View File

@ -1,4 +1,10 @@
deploy:
venv/bin/ansible-playbook -i hosts.yml playbook.yml -K
.PHONY: deploy
rollback:
venv/bin/ansible-playbook -i hosts.yml rollback.yml -K
logs:
ssh allison journalctl -efu misskey
.PHONY: deploy rollback

50
rollback.yml Normal file
View File

@ -0,0 +1,50 @@
---
- name: Rollback FoundKey
hosts:
- allison
vars:
user: misskey
service: misskey
source_repository: https://akkoma.dev/Michcio/FoundKey-0x7f
deploys_root: /var/lib/misskey/deploys
config_yml: /var/lib/misskey/default.yml
tasks:
- name: Checking which environment was previous
ansible.builtin.stat:
path: "{{ deploys_root }}/previous"
get_attributes: false
get_checksum: false
get_mime: false
follow: false
register: previous_current
become: true
become_user: "{{ user }}"
- name: Picking previous environment
ansible.builtin.set_fact:
deploy_dir: "{{ previous_current.stat.lnk_source }}"
run_once: true
- name: Print the chosen deployment directory
ansible.builtin.debug:
var: deploy_dir
run_once: true
- name: Deploy
block:
- name: Unlink previous deploy
become: true
become_user: "{{ user }}"
ansible.builtin.file:
dest: "{{ deploys_root }}/previous"
state: absent
- 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