netbird server works now. linted the yml files
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
---
|
||||
- name: Ensure 'caddy' container is connected to netbird_net
|
||||
community.docker.docker_network:
|
||||
name: netbird_net
|
||||
state: present
|
||||
connected:
|
||||
- caddy
|
||||
appends: true
|
||||
|
||||
- name: Read current Caddyfile
|
||||
ansible.builtin.slurp:
|
||||
path: "/var/lib/caddy/conf/Caddyfile"
|
||||
register: caddy_caddyfile_raw
|
||||
ignore_errors: true
|
||||
|
||||
- name: Decode Caddyfile content
|
||||
ansible.builtin.set_fact:
|
||||
caddy_caddyfile_content: "{{ caddy_caddyfile_raw['content'] | b64decode }}"
|
||||
|
||||
- name: Read snippet from template file
|
||||
ansible.builtin.set_fact:
|
||||
caddy_netbird_caddy_snippet: "{{ lookup('template', 'files/Caddyfile.j2') }}"
|
||||
|
||||
- name: Check if Netbird snippet already exists
|
||||
ansible.builtin.set_fact:
|
||||
caddy_snippet_present: "{{ caddy_netbird_caddy_snippet in caddy_caddyfile_content }}"
|
||||
|
||||
- name: Add Netbird snippet to Caddyfile
|
||||
ansible.builtin.blockinfile:
|
||||
path: "/var/lib/caddy/conf/Caddyfile"
|
||||
marker: "# {mark} Ansible managed Caddy snippet for Netbird"
|
||||
block: "{{ caddy_netbird_caddy_snippet }}"
|
||||
create: true
|
||||
mode: "0644"
|
||||
when: not caddy_snippet_present
|
||||
notify: Reload Caddy
|
||||
Reference in New Issue
Block a user