refactor: yml -> yaml
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
41
roles/reverse_proxy/tasks/30_custom_caddy.yaml
Normal file
41
roles/reverse_proxy/tasks/30_custom_caddy.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
- name: Check current diversion status for {{ reverse_proxy_default_caddy_path }}
|
||||
ansible.builtin.command:
|
||||
cmd: dpkg-divert --list {{ reverse_proxy_default_caddy_path }}
|
||||
register: divert_check_result
|
||||
changed_when: false # This task only checks state
|
||||
failed_when: false # Don't fail if diversion doesn't exist (rc=1)
|
||||
become: true
|
||||
|
||||
- name: Divert package manager's caddy binary path
|
||||
ansible.builtin.command:
|
||||
cmd: dpkg-divert --divert {{ reverse_proxy_diverted_caddy_path }} --rename {{ reverse_proxy_default_caddy_path }}
|
||||
# Only run if the diversion isn't already set correctly
|
||||
when: "reverse_proxy_diverted_caddy_path not in divert_check_result.stdout"
|
||||
notify: Restart caddy service # Notify restart if diversion happens
|
||||
become: true
|
||||
|
||||
- name: Copy custom Caddy binary to destination path
|
||||
ansible.builtin.copy:
|
||||
src: "{{ reverse_proxy_custom_caddy_source_path }}"
|
||||
dest: "{{ reverse_proxy_custom_caddy_dest_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
remote_src: true
|
||||
notify: Restart caddy service # Notify restart if binary changes
|
||||
become: true
|
||||
|
||||
- name: Install original (diverted) caddy binary alternative
|
||||
ansible.builtin.command:
|
||||
# Use --force if the link /usr/bin/caddy might exist but not be managed by alternatives yet
|
||||
cmd: update-alternatives --install {{ reverse_proxy_alternatives_link }} {{ reverse_proxy_alternatives_name }} {{ reverse_proxy_diverted_caddy_path }} 10
|
||||
changed_when: false # update-alternatives is idempotent but often reports no change via rc
|
||||
become: true
|
||||
|
||||
- name: Install custom caddy binary alternative with higher priority
|
||||
ansible.builtin.command:
|
||||
cmd: update-alternatives --install {{ reverse_proxy_alternatives_link }} {{ reverse_proxy_alternatives_name }} {{ reverse_proxy_custom_caddy_dest_path }} 50
|
||||
changed_when: false # update-alternatives is idempotent but often reports no change via rc
|
||||
notify: Restart caddy service
|
||||
become: true
|
||||
Reference in New Issue
Block a user