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

67 lines
2.1 KiB
YAML
Raw Normal View History

---
# Server/Caddyserver-Install: Install/Update Caddy Webserver (with some modules)
- name: Caddyserver - Create cache directory
ansible.builtin.file:
path: "{{ caddy_cachedir }}"
state: directory
2019-10-27 15:26:22 +00:00
- 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: true
register: caddy_releases_cache
2019-10-27 15:26:22 +00:00
- 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: true
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: true
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: true
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: true
ansible.builtin.service:
name: caddy
state: stopped
ignore_errors: true
- name: Caddyserver - Copy caddy to a PATH location
become: true
ansible.builtin.shell: "cp {{ caddy_cachedir }}/tmp/caddy /usr/local/bin"
- name: Caddyserver - Clean up download files
become: true
ansible.builtin.file:
path: "{{ caddy_cachedir }}/tmp"
state: absent