-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restart tunnels if their configuration has changed
If an existing tunnel confiugration gets rewritten, restart the tunnel. Also, only reload systemd when the unit file changes; it is not neccessary to daemon-reload just to enable a new instance.
- Loading branch information
Showing
3 changed files
with
21 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- name: Create config file for service '{{ item.key }}' | ||
template: | ||
src: config.yml.j2 | ||
dest: "{{ config_dir_tunnels }}/{{ item.key }}.yml" | ||
register: tunnel_template | ||
- name: Restart systemd service {{ item.key }} | ||
systemd: | ||
name: "{{ systemd_filename }}@{{ item.key }}" | ||
state: restarted | ||
enabled: yes | ||
no_block: no | ||
when: tunnel_template.changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,3 @@ | ||
- name: Create config file for service '{{ item.key }}' | ||
template: | ||
src: config.yml.j2 | ||
dest: "{{ config_dir_tunnels }}/{{ item.key }}.yml" | ||
- name: Configure tunnels | ||
include_tasks: add-tunnel.yml | ||
with_dict: "{{ tunnels }}" | ||
- name: Start systemd service {{ item.key }} | ||
systemd: | ||
name: "{{ systemd_filename }}@{{ item.key }}" | ||
state: started | ||
enabled: yes | ||
daemon_reload: yes | ||
no_block: no | ||
with_dict: "{{ tunnels }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
- name: Install cloudflared service for service '{{ tunnel_name }}'' | ||
template: | ||
src: cloudflared.service.j2 | ||
dest: "{{ systemd_target_dir }}/{{ systemd_filename }}@.service" | ||
dest: "{{ systemd_target_dir }}/{{ systemd_filename }}@.service" | ||
register: service_template | ||
- name: Reload systemd | ||
systemd: | ||
daemon_reload: yes | ||
no_block: no | ||
when: service_template.changed |