ansible-role-server/tasks/caddy-install.yml

54 lines
1.5 KiB
YAML
Raw Normal View History

---
# Server/Caddyserver-Install: Install/Update Caddy Webserver (with some modules)
2019-10-27 15:26:22 +00:00
# Detect some more host facts
- name: caddyserver - Detect debian distributor ID
shell: lsb_release -is
register: lsb_id
- name: caddyserver - Stop caddy
become: yes
service:
name: caddy
state: stopped
ignore_errors: yes
- name: caddyserver - Make temp download directory
file:
path: /tmp/caddy
state: directory
2019-10-27 15:26:22 +00:00
- name: caddyserver - Download caddy webserver (amd64)
get_url:
2019-10-27 15:26:22 +00:00
url: "https://caddyserver.com/download/linux/amd64?plugins=http.ratelimit&license=personal"
dest: /tmp/caddy/caddy.tar.gz
2019-10-27 15:26:22 +00:00
when: lsb_id.stdout != "Raspbian"
- name: caddyserver - Download caddy webserver (raspberry pi)
get_url:
url: "https://caddyserver.com/download/linux/arm7?plugins=http.ratelimit&license=personal"
dest: /tmp/caddy/caddy.tar.gz
when: lsb_id.stdout == "Raspbian"
- name: caddyserver - Extract caddy
shell: "cd /tmp/caddy && tar -xvf caddy.tar.gz"
- name: caddyserver - Copy caddy to a PATH location
become: yes
shell: "cp /tmp/caddy/caddy /usr/local/bin"
- name: caddyserver - Clean up download files
become: yes
file:
path: /tmp/caddy
state: absent
- name: caddyserver - Install caddy APT dependencies
become: yes
apt:
name: libcap2-bin
state: present
- name: caddyserver - Give caddy port binding capabilities
become: yes
shell: "setcap cap_net_bind_service=+ep /usr/local/bin/caddy"
# capabilities:
# path: "{{ caddy_bin }}"
# capability: cap_net_bind_service+ep
# state: present