summaryrefslogtreecommitdiff
path: root/roles/web/tasks/build_hugo_sites.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/web/tasks/build_hugo_sites.yaml')
-rw-r--r--roles/web/tasks/build_hugo_sites.yaml66
1 files changed, 66 insertions, 0 deletions
diff --git a/roles/web/tasks/build_hugo_sites.yaml b/roles/web/tasks/build_hugo_sites.yaml
new file mode 100644
index 00000000..f3852133
--- /dev/null
+++ b/roles/web/tasks/build_hugo_sites.yaml
@@ -0,0 +1,66 @@
+---
+- name: "make build directory"
+ delegate_to: localhost
+ ansible.builtin.file:
+ path: "{{ item }}"
+ state: directory
+ loop:
+ - "{{ inventory_dir }}/.hugo_sites_build"
+ - "{{ inventory_dir }}/.built_sites"
+
+- name: "copy specific folders to hugo_tmp for each user"
+ delegate_to: localhost
+ ansible.builtin.shell: "rsync -avz {{ inventory_dir }}/web/ {{ inventory_dir }}/.hugo_sites_build/{{ item }} {{ '--exclude=anyconnect.md' if 'ocserv' not in user_pass_dict[item] }} {{'--exclude=openconnect.md' if 'ocserv' not in user_pass_dict[item] }} {{'--exclude=nekobox.md' if ['trojan','vmess','vless']|intersect(user_pass_dict[item]) == {} }} {{'--exclude=nekoray.md' if ['trojan','vmess','vless']|intersect(user_pass_dict[item]) == {} }} {{'--exclude=nekossh.md' if 'sshvpn' not in user_pass_dict[item] }}"
+ loop: "{{ user_pass_dict.keys() }}"
+
+- name: "template out hugo.toml"
+ delegate_to: localhost
+ ansible.builtin.template:
+ src: "{{ inventory_dir }}/.hugo_sites_build/{{ item }}/hugo.toml.j2"
+ dest: "{{ inventory_dir }}/.hugo_sites_build/{{ item }}/hugo.toml"
+ loop: "{{ user_pass_dict.keys() }}"
+
+- name: "template out vars"
+ ansible.builtin.include_tasks: template_vars.yaml
+ loop:
+ - content.en
+ - content.fa
+ loop_control:
+ loop_var: content_dir
+
+- name: "copy hugo_build.sh to temp dir"
+ delegate_to: localhost
+ ansible.builtin.copy:
+ src: "{{ inventory_dir }}/utils/hugo_build.sh"
+ dest: ".hugo_sites_build/hugo_build.sh"
+
+- name: "build hugo sites"
+ delegate_to: localhost
+ ansible.builtin.shell: "sh {{ inventory_dir }}/.hugo_sites_build/hugo_build.sh"
+
+- name: "copy sites"
+ ansible.posix.synchronize:
+ src: "{{ inventory_dir }}/.built_sites/" # this will only copy contents
+ dest: /var/www/reactance
+
+- name: "copy images"
+ ansible.posix.synchronize:
+ src: "{{ inventory_dir }}/web/static/images/"
+ dest: /var/www/reactance/images
+
+- name: "charge dir permissions"
+ ansible.builtin.file:
+ dest: /var/www/reactance
+ owner: www
+ group: daemon
+ mode: 0755
+ recurse: yes
+
+- name: "remove build directory"
+ delegate_to: localhost
+ ansible.builtin.file:
+ path: "{{ item }}"
+ state: absent
+ loop:
+ - "{{ inventory_dir }}/.hugo_sites_build"
+ - "{{ inventory_dir }}/.built_sites"