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
dogeystamp 449a0a6cca
website: migrate to barf
new more robust deployment system too
2023-05-14 17:34:22 -04:00

67 lines
1.4 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: Create website deployment user
user:
name: "{{ web_username }}"
- name: Install required packages
community.general.pacman:
name:
- git
- make
- lowdown
- rsync
state: present
- name: Fetch site source
git:
dest: "/home/{{ web_username }}/website"
repo: "{{ site_repo }}"
register: site_source
become_user: "{{ web_username }}"
- name: Make site directory in web root
file:
group: http
owner: "{{ web_username }}"
path: "{{ fullroot }}"
state: directory
register: site_folder
- name: Deploy source to web root
make:
chdir: "/home/{{ web_username }}/website"
target: deploy
params:
OUTPUT: "{{ fullroot }}"
when: site_source.changed or site_folder.changed
become_user: "{{ web_username }}"
- name: Send deployment script
template:
src: deploy.sh.j2
dest: "/home/{{ web_username }}/deploy.sh"
mode: 0700
owner: "{{ web_username }}"
- name: Tell cron to mail to root
cron:
user: "{{ web_username }}"
name: MAILTO
env: yes
job: root
- name: Cronjob to deploy source
cron:
user: "{{ web_username }}"
name: "Update and deploy website source"
minute: 0
hour: "*/1"
job: "chronic /home/{{ web_username }}/deploy.sh"