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
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.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
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.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
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.file:
|
2019-11-30 17:37:34 +00:00
|
|
|
path: "{{ caddy_cachedir }}/tmp"
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: caddyserver - Download caddy webserver (amd64)
|
2020-09-14 21:48:51 +00:00
|
|
|
become: yes
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.get_url:
|
2020-09-14 21:48:51 +00:00
|
|
|
url: "https://caddyserver.com/api/download?os=linux&arch=amd64"
|
|
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy"
|
|
|
|
group: root
|
|
|
|
owner: root
|
|
|
|
mode: 0755
|
2020-04-17 10:14:25 +00:00
|
|
|
when: ansible_architecture == "x86_64"
|
|
|
|
- name: caddyserver - Download caddy webserver (armv7/ raspberry pi)
|
2020-09-14 21:48:51 +00:00
|
|
|
become: yes
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.get_url:
|
2020-09-14 21:48:51 +00:00
|
|
|
url: "https://caddyserver.com/api/download?os=linux&arch=arm&arm=7"
|
|
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy"
|
|
|
|
group: root
|
|
|
|
owner: root
|
|
|
|
mode: 0755
|
2020-04-17 10:14:25 +00:00
|
|
|
when: ansible_architecture == "armv7l"
|
|
|
|
- name: caddyserver - Download caddy webserver (arm64)
|
2020-09-14 21:48:51 +00:00
|
|
|
become: yes
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.get_url:
|
2020-09-14 21:48:51 +00:00
|
|
|
url: "https://caddyserver.com/api/download?os=linux&arch=arm64"
|
|
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy"
|
|
|
|
group: root
|
|
|
|
owner: root
|
|
|
|
mode: 0755
|
2020-04-17 10:14:25 +00:00
|
|
|
when: ansible_architecture == "aarch64"
|
2019-11-30 17:37:34 +00:00
|
|
|
|
|
|
|
- name: caddyserver - Stop caddy
|
|
|
|
become: yes
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.service:
|
2019-11-30 17:37:34 +00:00
|
|
|
name: caddy
|
|
|
|
state: stopped
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: caddyserver - Copy caddy to a PATH location
|
|
|
|
become: yes
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.shell: "cp {{ caddy_cachedir }}/tmp/caddy /usr/local/bin"
|
2019-11-30 17:37:34 +00:00
|
|
|
- name: caddyserver - Clean up download files
|
|
|
|
become: yes
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.file:
|
2019-11-30 17:37:34 +00:00
|
|
|
path: "{{ caddy_cachedir }}/tmp"
|
|
|
|
state: absent
|
|
|
|
when: caddy_releases_cache.changed
|