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