67 lines
1.4 KiB
YAML
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"
|