From 75571227745c3ad86be2c43a14bec264d1eb39cd Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sat, 23 May 2020 03:48:26 +0000 Subject: [PATCH] Add plays to backup and install a hexo server --- ansible/plays/hexo-backup.yml | 13 +++++++++++++ ansible/plays/hexo-install.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 ansible/plays/hexo-backup.yml create mode 100644 ansible/plays/hexo-install.yml diff --git a/ansible/plays/hexo-backup.yml b/ansible/plays/hexo-backup.yml new file mode 100644 index 0000000..e0bec07 --- /dev/null +++ b/ansible/plays/hexo-backup.yml @@ -0,0 +1,13 @@ +--- +- hosts: hexo + become: yes + tasks: + - name: Backup Hexo files + archive: + path: /home/hexouser/blogsite + dest: /home/hexouser/blogsite.tgz + - name: Fetching backup files + fetch: + src: /home/hexouser/blogsite.tgz + dest: /home/ansibleuser/backups/ + flat: yes diff --git a/ansible/plays/hexo-install.yml b/ansible/plays/hexo-install.yml new file mode 100644 index 0000000..ef8aa09 --- /dev/null +++ b/ansible/plays/hexo-install.yml @@ -0,0 +1,34 @@ +--- +- name: Install Hexo static site generator + hosts: hexo + become: yes + tasks: + - name: Update apt sources and install npm + apt: + name: npm + state: present + update_cache: yes + - name: Install hexo-cli + npm: + name: hexo-cli + global: yes + - name: Adding hexo user / administrator + user: + name: hexouser + shell: /bin/bash + groups: sudo + uid: 1003 + - name: Initialize site files + command: + chdir: /home/hexouser/ + cmd: hexo init blogsite + - name: Install site packages + npm: + path: /home/hexouser/blogsite/ + - name: Start server + command: + chdir: /home/hexouser/blogsite/ + cmd: nohup hexo server & + async: 45 + poll: 0 +