Jannik Beyerstedt
a0ac0a67a7
Having the when condition of a task at the top instead of bottom is easiert to read. Also some spaces were another whitespace character on accident.
67 lines
2.1 KiB
YAML
67 lines
2.1 KiB
YAML
---
|
|
# Server/Caddyserver-Install: Install/Update Caddy Webserver (with some modules)
|
|
|
|
- name: caddyserver - Create cache directory
|
|
ansible.builtin.file:
|
|
path: "{{ caddy_cachedir }}"
|
|
state: directory
|
|
|
|
- name: caddyserver - Get all caddy releases
|
|
ansible.builtin.get_url:
|
|
url: https://api.github.com/repos/caddyserver/caddy/git/refs/tags
|
|
dest: "{{ caddy_cachedir }}/releases.txt"
|
|
force: yes
|
|
register: caddy_releases_cache
|
|
|
|
- name: caddyserver - Install or update
|
|
when: caddy_releases_cache.changed
|
|
block:
|
|
- name: caddyserver - Make temp download directory
|
|
ansible.builtin.file:
|
|
path: "{{ caddy_cachedir }}/tmp"
|
|
state: directory
|
|
|
|
- name: caddyserver - Download caddy webserver (amd64)
|
|
when: ansible_architecture == "x86_64"
|
|
become: yes
|
|
ansible.builtin.get_url:
|
|
url: "https://caddyserver.com/api/download?os=linux&arch=amd64"
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy"
|
|
group: root
|
|
owner: root
|
|
mode: 0755
|
|
- name: caddyserver - Download caddy webserver (armv7/ raspberry pi)
|
|
when: ansible_architecture == "armv7l"
|
|
become: yes
|
|
ansible.builtin.get_url:
|
|
url: "https://caddyserver.com/api/download?os=linux&arch=arm&arm=7"
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy"
|
|
group: root
|
|
owner: root
|
|
mode: 0755
|
|
- name: caddyserver - Download caddy webserver (arm64)
|
|
when: ansible_architecture == "aarch64"
|
|
become: yes
|
|
ansible.builtin.get_url:
|
|
url: "https://caddyserver.com/api/download?os=linux&arch=arm64"
|
|
dest: "{{ caddy_cachedir }}/tmp/caddy"
|
|
group: root
|
|
owner: root
|
|
mode: 0755
|
|
|
|
- name: caddyserver - Stop caddy
|
|
become: yes
|
|
ansible.builtin.service:
|
|
name: caddy
|
|
state: stopped
|
|
ignore_errors: yes
|
|
|
|
- name: caddyserver - Copy caddy to a PATH location
|
|
become: yes
|
|
ansible.builtin.shell: "cp {{ caddy_cachedir }}/tmp/caddy /usr/local/bin"
|
|
- name: caddyserver - Clean up download files
|
|
become: yes
|
|
ansible.builtin.file:
|
|
path: "{{ caddy_cachedir }}/tmp"
|
|
state: absent
|