2019-10-06 20:55:56 +00:00
|
|
|
---
|
|
|
|
# Server/Caddyserver-Install: Install/Update Caddy Webserver (with some modules)
|
|
|
|
|
2019-11-30 17:37:34 +00:00
|
|
|
- name: caddyserver - Create cache directory
|
2019-10-06 20:55:56 +00:00
|
|
|
file:
|
2019-11-30 17:37:34 +00:00
|
|
|
path: "{{ caddy_cachedir }}"
|
2019-10-06 20:55:56 +00:00
|
|
|
state: directory
|
2019-10-27 15:26:22 +00:00
|
|
|
|
2019-11-30 17:37:34 +00:00
|
|
|
- name: caddyserver - Get all caddy releases
|
2019-10-27 15:26:22 +00:00
|
|
|
get_url:
|
2019-11-30 17:37:34 +00:00
|
|
|
url: https://api.github.com/repos/caddyserver/caddy/git/refs/tags
|
|
|
|
dest: "{{ caddy_cachedir }}/releases.txt"
|
|
|
|
force: yes
|
|
|
|
register: caddy_releases_cache
|
2019-10-27 15:26:22 +00:00
|
|
|
|
2019-11-30 17:37:34 +00:00
|
|
|
- name: caddyserver - Install or update
|
|
|
|
block:
|
|
|
|
- name: caddyserver - Make temp download directory
|
|
|
|
file:
|
|
|
|
path: "{{ caddy_cachedir }}/tmp"
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: caddyserver - Download caddy webserver (amd64)
|
|
|
|
get_url:
|
2020-05-24 15:08:11 +00:00
|
|
|
url: "https://caddyserver.com/download/linux/amd64?plugins={{ caddy_plugins }}&license=personal"
|
2019-11-30 17:37:34 +00:00
|
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy.tar.gz"
|
2020-04-17 10:14:25 +00:00
|
|
|
when: ansible_architecture == "x86_64"
|
|
|
|
- name: caddyserver - Download caddy webserver (armv7/ raspberry pi)
|
2019-11-30 17:37:34 +00:00
|
|
|
get_url:
|
2020-05-24 15:08:11 +00:00
|
|
|
url: "https://caddyserver.com/download/linux/arm7?plugins={{ caddy_plugins }}&license=personal"
|
2019-11-30 17:37:34 +00:00
|
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy.tar.gz"
|
2020-04-17 10:14:25 +00:00
|
|
|
when: ansible_architecture == "armv7l"
|
|
|
|
- name: caddyserver - Download caddy webserver (arm64)
|
|
|
|
get_url:
|
2020-05-24 15:08:11 +00:00
|
|
|
url: "https://caddyserver.com/download/linux/arm64?plugins={{ caddy_plugins }}&license=personal"
|
2020-04-17 10:14:25 +00:00
|
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy.tar.gz"
|
|
|
|
when: ansible_architecture == "aarch64"
|
2019-11-30 17:37:34 +00:00
|
|
|
|
|
|
|
- name: caddyserver - Stop caddy
|
|
|
|
become: yes
|
|
|
|
service:
|
|
|
|
name: caddy
|
|
|
|
state: stopped
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: caddyserver - Extract caddy
|
|
|
|
shell: "cd {{ caddy_cachedir }}/tmp && tar -xvf caddy.tar.gz"
|
|
|
|
- name: caddyserver - Copy caddy to a PATH location
|
|
|
|
become: yes
|
|
|
|
shell: "cp {{ caddy_cachedir }}/tmp/caddy /usr/local/bin"
|
|
|
|
- name: caddyserver - Clean up download files
|
|
|
|
become: yes
|
|
|
|
file:
|
|
|
|
path: "{{ caddy_cachedir }}/tmp"
|
|
|
|
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
|
|
|
|
when: caddy_releases_cache.changed
|