change hugo role variable structure
This commit is contained in:
parent
1a04e81df0
commit
b141808b78
@ -35,12 +35,13 @@ users:
|
|||||||
cuqmbr.xyz_gitea-actions"
|
cuqmbr.xyz_gitea-actions"
|
||||||
opendoas_settings: "permit nopass gitea-actions"
|
opendoas_settings: "permit nopass gitea-actions"
|
||||||
|
|
||||||
hugo_version: 0.147.9
|
hugo_settings:
|
||||||
hugo_homedir: /opt/hugo
|
version: 0.147.9
|
||||||
hugo_git_repo: https://gitea.cuqmbr.xyz/cuqmbr/cuqmbr.xyz.git
|
homedir: /opt/hugo
|
||||||
hugo_git_commit: 585a8ad8ca4cfeab4df7ae5d852f5fb616b72aca
|
git_repo: https://gitea.cuqmbr.xyz/cuqmbr/cuqmbr.xyz.git
|
||||||
hugo_git_refspec: refs/heads/main
|
git_commit: 472f87aacdcd8d628103d1c6c140981b5417b130
|
||||||
hugo_base_url: http://dev.cuqmbr.xyz
|
git_refspec: refs/heads/main
|
||||||
|
base_url: http://dev.cuqmbr.xyz
|
||||||
|
|
||||||
nginx_settings:
|
nginx_settings:
|
||||||
server_tokens: false
|
server_tokens: false
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
hugo_version: 0.147.9
|
hugo_settings:
|
||||||
hugo_homedir: /opt/hugo
|
|
||||||
hugo_git_repo: https://gitea.cuqmbr.xyz/cuqmbr/cuqmbr.xyz.git
|
hugo_default_settings:
|
||||||
hugo_git_commit: 5b894854d47b41996b1901fa257f8c2cad9224f9
|
version: 0.147.9
|
||||||
hugo_git_refspec: refs/heads/main
|
homedir: /opt/hugo
|
||||||
hugo_base_url: https://cuqmbr.xyz
|
git_repo: https://gitea.cuqmbr.xyz/cuqmbr/cuqmbr.xyz.git
|
||||||
|
git_commit: 472f87aacdcd8d628103d1c6c140981b5417b130
|
||||||
|
git_refspec: refs/heads/main
|
||||||
|
base_url: https://cuqmbr.xyz
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- name: Combine default and user settings, decrypt vault.
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
hugo_settings: "{{ hugo_default_settings |
|
||||||
|
ansible.builtin.combine(hugo_settings, recursive=true) }}"
|
||||||
|
no_log: true
|
||||||
|
|
||||||
- name: Install hugo deb package from github.
|
- name: Install hugo deb package from github.
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
deb: "https://github.com/gohugoio/hugo/releases/download\
|
deb: "https://github.com/gohugoio/hugo/releases/download\
|
||||||
/v{{ hugo_version}}/\
|
/v{{ hugo_settings.version}}/\
|
||||||
hugo_{{ hugo_version }}_linux-amd64.deb"
|
hugo_{{ hugo_settings.version }}_linux-amd64.deb"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Install dependencies using apt.
|
- name: Install dependencies using apt.
|
||||||
@ -14,61 +20,65 @@
|
|||||||
|
|
||||||
- name: Set hugo_source, hugo_compiled and hugo_deploy variables.
|
- name: Set hugo_source, hugo_compiled and hugo_deploy variables.
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
hugo_source: "{{ hugo_homedir }}/src"
|
hugo_source: "{{ hugo_settings.homedir }}/src"
|
||||||
hugo_compiled: "{{ hugo_homedir }}/compiled"
|
hugo_compiled: "{{ hugo_settings.homedir }}/compiled"
|
||||||
hugo_deploy: /var/www/hugo
|
hugo_deploy: /var/www/hugo
|
||||||
|
|
||||||
- name: Clone hugo site git repository.
|
- name: Clone hugo site git repository.
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
clone: true
|
clone: true
|
||||||
repo: "{{ hugo_git_repo }}"
|
repo: "{{ hugo_settings.git_repo }}"
|
||||||
force: true
|
force: true
|
||||||
recursive: true
|
recursive: true
|
||||||
single_branch: true
|
single_branch: true
|
||||||
depth: 1
|
depth: 1
|
||||||
dest: "{{ hugo_source }}"
|
dest: "{{ hugo_source }}"
|
||||||
version: "{{ hugo_git_commit }}"
|
version: "{{ hugo_settings.git_commit }}"
|
||||||
refspec: "{{ hugo_git_refspec }}"
|
refspec: "{{ hugo_settings.git_refspec }}"
|
||||||
|
register: git_clone_result
|
||||||
|
|
||||||
- name: Create hugo site build directory.
|
- name: Create hugo site build directory.
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0775"
|
mode: "0755"
|
||||||
path: "{{ hugo_compiled }}"
|
path: "{{ hugo_compiled }}"
|
||||||
|
|
||||||
- name: Remove old compiled files.
|
- name: Compile and insatll.
|
||||||
ansible.builtin.file:
|
when: git_clone_result.changed
|
||||||
path: "{{ hugo_compiled }}"
|
block:
|
||||||
state: absent
|
- name: Remove old compiled files.
|
||||||
changed_when: false
|
ansible.builtin.file:
|
||||||
|
path: "{{ hugo_compiled }}"
|
||||||
|
state: absent
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Build hugo site.
|
- name: Build hugo site.
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
chdir: "{{ hugo_source }}"
|
chdir: "{{ hugo_source }}"
|
||||||
cmd: "hugo -b {{ hugo_base_url }} -d {{ hugo_compiled }}"
|
cmd: "hugo -b {{ hugo_settings.base_url }} -d {{ hugo_compiled }}"
|
||||||
|
|
||||||
- name: Create hugo site deployment directory.
|
- name: Create hugo site deployment directory.
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0775"
|
mode: "0775"
|
||||||
path: "{{ hugo_deploy }}"
|
path: "{{ hugo_deploy }}"
|
||||||
|
|
||||||
- name: Remove old deployed files.
|
- name: Remove old deployed files.
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ hugo_deploy }}"
|
path: "{{ hugo_deploy }}"
|
||||||
state: absent
|
state: absent
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Install new program files.
|
- name: Install new program files.
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
remote_src: true
|
remote_src: true
|
||||||
src: "{{ hugo_compiled }}/"
|
src: "{{ hugo_compiled }}/"
|
||||||
dest: "{{ hugo_deploy }}"
|
dest: "{{ hugo_deploy }}"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0775"
|
mode: "0775"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
Loading…
Reference in New Issue
Block a user