galaxy-caddy/tasks/main.yml

79 lines
2 KiB
YAML
Raw Normal View History

2019-02-01 14:22:04 +00:00
---
# tasks file for galaxy-caddy
- name: Create Caddy user
user: name=caddy
system=yes
createhome=yes
home={{ caddy_home }}
shell=/bin/nologin
tags: user
- name: Download new Caddy version or build
2020-05-19 19:26:04 +00:00
get_url: url=https://github.com/caddyserver/caddy/releases/download/v{{ caddy_version }}/caddy_{{ caddy_version }}_linux_amd64.tar.gz
dest=/tmp/caddy_{{ caddy_version }}.tar.gz
2019-02-01 14:22:04 +00:00
force=yes
register: caddy_binary_cache
- name: Extract new Caddy version or build
2020-05-19 19:26:04 +00:00
unarchive: src=/tmp/caddy_{{ caddy_version }}.tar.gz
2019-02-01 14:22:04 +00:00
dest=/usr/bin/
copy=no
2020-10-18 19:02:23 +00:00
notify: restart caddy
2019-02-01 14:22:04 +00:00
when: caddy_binary_cache.changed
- name: Ensure setcap bin
apt: name=libcap2-bin
state=present
- name: Check if the binary can bind to TCP port <1024
shell: getcap /usr/bin/caddy | grep cap_net_bind_service
failed_when: False
changed_when: False
register: caddy_bind_cap
- name: Set capability on the binary file to be able to bind to TCP port <1024
command: setcap cap_net_bind_service=+ep /usr/bin/caddy
when: caddy_bind_cap.rc > 0
- name: Create caddy needed directories
file: path={{ item }}
state=directory
owner=caddy
with_items:
- "{{ caddy_conf }}"
- "{{ caddy_confd }}"
2020-03-20 13:32:10 +00:00
- "{{ caddy_logs }}"
2019-02-01 14:22:04 +00:00
- "{{ caddy_www }}"
- name: Caddyfile
template: src=caddyfile.j2
dest={{ caddy_conf }}/Caddyfile
notify: restart caddy
- name: Push vhost test page caddy config
template: src=http.caddy.j2
dest={{ caddy_confd }}/test.caddy
notify: restart caddy
- name: Create test www dir
file: path={{ caddy_www }}/test
state=directory
owner=caddy
group=caddy
- name: Push test page source
copy: src=test.html
dest={{ caddy_www }}/test/index.html
- name: Create Test page logs dir
2020-03-20 13:32:10 +00:00
file: path={{ caddy_logs }}/test
2019-02-01 14:22:04 +00:00
state=directory
owner=caddy
- name: Systemd service
template: src=caddy.service.j2
dest=/etc/systemd/system/caddy.service
notify:
- start caddy