2019-10-06 20:55:56 +00:00
|
|
|
---
|
|
|
|
# Server/Caddyserver-Install: Install/Update Caddy Webserver (with some modules)
|
|
|
|
|
2023-04-28 21:25:21 +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
|
|
|
|
2023-04-28 21:25:21 +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"
|
2023-04-28 21:25:21 +00:00
|
|
|
force: true
|
2019-11-30 17:37:34 +00:00
|
|
|
register: caddy_releases_cache
|
2019-10-27 15:26:22 +00:00
|
|
|
|
2023-04-28 21:25:21 +00:00
|
|
|
- name: Caddyserver - Install or update
|
2022-02-13 19:52:02 +00:00
|
|
|
when: caddy_releases_cache.changed
|
2019-11-30 17:37:34 +00:00
|
|
|
block:
|
2023-04-28 21:25:21 +00:00
|
|
|
- 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
|
|
|
|
|
2023-04-28 21:25:21 +00:00
|
|
|
- name: Caddyserver - Download caddy webserver (amd64)
|
2022-02-13 19:52:02 +00:00
|
|
|
when: ansible_architecture == "x86_64"
|
2023-04-28 21:25:21 +00:00
|
|
|
become: true
|
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
|
2023-04-28 21:25:21 +00:00
|
|
|
mode: "0755"
|
|
|
|
- name: Caddyserver - Download caddy webserver (armv7/ raspberry pi)
|
2022-02-13 19:52:02 +00:00
|
|
|
when: ansible_architecture == "armv7l"
|
2023-04-28 21:25:21 +00:00
|
|
|
become: true
|
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
|
2023-04-28 21:25:21 +00:00
|
|
|
mode: "0755"
|
|
|
|
- name: Caddyserver - Download caddy webserver (arm64)
|
2022-02-13 19:52:02 +00:00
|
|
|
when: ansible_architecture == "aarch64"
|
2023-04-28 21:25:21 +00:00
|
|
|
become: true
|
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
|
2023-04-28 21:25:21 +00:00
|
|
|
mode: "0755"
|
2019-11-30 17:37:34 +00:00
|
|
|
|
2023-04-28 21:25:21 +00:00
|
|
|
- name: Caddyserver - Stop caddy
|
|
|
|
become: true
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.service:
|
2019-11-30 17:37:34 +00:00
|
|
|
name: caddy
|
|
|
|
state: stopped
|
2023-04-28 21:25:21 +00:00
|
|
|
ignore_errors: true
|
2019-11-30 17:37:34 +00:00
|
|
|
|
2023-04-28 21:25:21 +00:00
|
|
|
- name: Caddyserver - Copy caddy to a PATH location
|
|
|
|
become: true
|
2021-08-28 14:50:37 +00:00
|
|
|
ansible.builtin.shell: "cp {{ caddy_cachedir }}/tmp/caddy /usr/local/bin"
|
2023-04-28 21:25:21 +00:00
|
|
|
- name: Caddyserver - Clean up download files
|
|
|
|
become: true
|
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
|