74 lines
1.7 KiB
YAML
74 lines
1.7 KiB
YAML
---
|
|
|
|
- name: Install hugo deb package from github.
|
|
ansible.builtin.apt:
|
|
deb: "https://github.com/gohugoio/hugo/releases/download\
|
|
/v{{ hugo_version}}/\
|
|
hugo_{{ hugo_version }}_linux-amd64.deb"
|
|
state: present
|
|
|
|
- name: Install dependencies using apt.
|
|
ansible.builtin.apt:
|
|
name: git
|
|
state: present
|
|
|
|
- name: Set hugo_source, hugo_compiled and hugo_deploy variables.
|
|
ansible.builtin.set_fact:
|
|
hugo_source: "{{ hugo_homedir }}/src"
|
|
hugo_compiled: "{{ hugo_homedir }}/compiled"
|
|
hugo_deploy: /var/www/hugo
|
|
|
|
- name: Clone hugo site git repository.
|
|
ansible.builtin.git:
|
|
clone: true
|
|
repo: "{{ hugo_git_repo }}"
|
|
force: true
|
|
recursive: true
|
|
single_branch: true
|
|
depth: 1
|
|
dest: "{{ hugo_source }}"
|
|
version: "{{ hugo_git_commit }}"
|
|
|
|
- name: Create hugo site build directory.
|
|
ansible.builtin.file:
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: "0775"
|
|
path: "{{ hugo_compiled }}"
|
|
|
|
- name: Remove old compiled files.
|
|
ansible.builtin.file:
|
|
path: "{{ hugo_compiled }}"
|
|
state: absent
|
|
changed_when: false
|
|
|
|
- name: Build hugo site.
|
|
ansible.builtin.shell:
|
|
chdir: "{{ hugo_source }}"
|
|
cmd: "hugo -d {{ hugo_compiled }}"
|
|
|
|
- name: Create hugo site deployment directory.
|
|
ansible.builtin.file:
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: "0775"
|
|
path: "{{ hugo_deploy }}"
|
|
|
|
- name: Remove old deployed files.
|
|
ansible.builtin.file:
|
|
path: "{{ hugo_deploy }}"
|
|
state: absent
|
|
changed_when: false
|
|
|
|
- name: Install new program files.
|
|
ansible.builtin.copy:
|
|
remote_src: true
|
|
src: "{{ hugo_compiled }}/"
|
|
dest: "{{ hugo_deploy }}"
|
|
owner: root
|
|
group: root
|
|
mode: "0775"
|
|
changed_when: false
|