This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
homeserver-ansible/roles/services/website/tasks/main.yml

54 lines
1.2 KiB
YAML

- name: Set site path
set_fact:
path: "{{ server_blocks.website.domain }}{{ nginx_services.website.path }}"
- name: Set full root
set_fact:
fullroot: "{{ webroot }}/{{ path }}"
- name: Install required packages
community.general.pacman:
name:
- cpio
- lowdown
state: present
- name: Create site source folder
file:
owner: http
group: http
path: "/srv/web_source"
state: directory
recurse: yes
register: site_perm
- name: Fetch site source
git:
dest: "/srv/web_source"
repo: "{{ site_repo }}"
register: site_source
become_user: http
- name: Make site directory in web root
file:
group: http
owner: http
path: "{{ fullroot }}"
state: directory
register: site_folder
- name: Deploy source to web root
shell:
cmd: "./ssg6 src {{ fullroot }} '{{ web_name }}' 'https://{{ path }}'"
chdir: /srv/web_source
when: site_source.changed or site_folder.changed or site_perm.changed
become_user: http
- name: Cronjob to deploy source
cron:
user: http
name: "Update and deploy website source"
minute: 0
hour: "*/12"
job: "git -C /srv/web_source/ pull && /srv/web_source/ssg6 /srv/web_source/src {{ fullroot }} '{{ web_name }}' 'https://{{ path }}'"