68 lines
2.2 KiB
YAML
68 lines
2.2 KiB
YAML
---
|
|
- hosts: nimbus-1.net.enp.one
|
|
name: Deploy documentation
|
|
vars:
|
|
# Local directory to use for cloning and building the documentation site
|
|
DIR_BUILD: /tmp/docs
|
|
# Remote directory to install the site at
|
|
DIR_DEPLOY: /usr/share/nginx/doc.enp.one/html
|
|
tasks:
|
|
- name: Build the static site locally
|
|
delegate_to: 127.0.0.1
|
|
block:
|
|
- name: Ensure the build directory does not exist
|
|
file:
|
|
path: "{{ DIR_BUILD }}"
|
|
state: absent
|
|
- name: Clone documentation repository
|
|
git:
|
|
repo: git@vcs.enp.one:omni/omni-docs.git
|
|
dest: "{{ DIR_BUILD }}/"
|
|
- name: Generate build env requirements file
|
|
# Generate the requirements.txt style format, pipe through grep to remove
|
|
# the index line (not sure why thats included at all tbh) and save the
|
|
# result in "requirements.txt" to usage with pip
|
|
shell: pipenv lock --requirements | grep --invert-match "\-i">requirements.txt
|
|
args:
|
|
chdir: "{{ DIR_BUILD }}/"
|
|
- name: Create build env and install requirements
|
|
pip:
|
|
requirements: "{{ DIR_BUILD }}/requirements.txt"
|
|
virtualenv: "{{ DIR_BUILD }}/venv"
|
|
virtualenv_python: python3
|
|
state: present
|
|
- name: Build the static site using mkdocs
|
|
shell: "{{ DIR_BUILD }}/venv/bin/mkdocs build"
|
|
args:
|
|
chdir: "{{ DIR_BUILD }}"
|
|
|
|
- name: Upload static site to remote
|
|
copy:
|
|
src: "{{ DIR_BUILD }}/site/"
|
|
dest: "/tmp/docs/"
|
|
- name: Remove legacy site
|
|
become: true
|
|
file:
|
|
path: "{{ DIR_DEPLOY }}"
|
|
state: absent
|
|
- name: Copy static site to deployment directory
|
|
become: true
|
|
copy:
|
|
src: "/tmp/docs/"
|
|
dest: "{{ DIR_DEPLOY }}"
|
|
remote_src: true
|
|
owner: root
|
|
group: nginx
|
|
mode: 0755
|
|
setype: httpd_sys_content_t
|
|
|
|
- name: Clean up local build directory
|
|
delegate_to: 127.0.0.1
|
|
file:
|
|
path: "{{ DIR_BUILD }}"
|
|
state: absent
|
|
- name: Clean up remote temp directory
|
|
file:
|
|
path: /tmp/docs
|
|
state: absent
|