-
-
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.
Browse files
Browse the repository at this point in the history
Add cleanup of legacy stuff
- Loading branch information
Showing
9 changed files
with
111 additions
and
68 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
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
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,21 @@ | ||
- name: Define required variables for cleanup | ||
set_fact: | ||
daemon_location: "{{ install_target_dir }}/cloudflared" | ||
tunnel_name: "{{ item.key }}" | ||
config_filename_legacy: "config.{{ item.key }}.yml" | ||
systemd_filename_legacy: "cloudflared-{{ item.key }}.service" | ||
- name: Stop systemd service {{ systemd_filename_legacy }} | ||
systemd: | ||
name: "{{ systemd_filename_legacy }}" | ||
state: stopped | ||
enabled: no | ||
daemon_reload: yes | ||
ignore_errors: true | ||
- name: Remove legacy config files | ||
file: | ||
path: "{{ config_dir_tunnels }}/{{ config_filename_legacy }}" | ||
state: absent | ||
- name: Remove legacy cloudflared service files | ||
file: | ||
path: "{{ systemd_target_dir }}/{{ systemd_filename_legacy }}" | ||
state: absent |
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,13 @@ | ||
- name: Create config file for service '{{ item.key }}' | ||
template: | ||
src: config.yml.j2 | ||
dest: "{{ config_dir_tunnels }}/{{ item.key }}.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,19 +1,8 @@ | ||
- name: Define required variables for configuration | ||
set_fact: | ||
daemon_location: "{{ install_target_dir }}/cloudflared" | ||
config_filename: "config.{{ service_name }}.yml" | ||
systemd_filename: "cloudflared-{{ service_name }}.service" | ||
- name: Create config file for service '{{ service_name }}' | ||
template: | ||
src: config.yml.j2 | ||
dest: "{{ config_dir_tunnels }}/{{ config_filename }}" | ||
- name: Install cloudflared service for service '{{ service_name }}'' | ||
systemd_filename: "cloudflared" | ||
- name: Install cloudflared service for service '{{ tunnel_name }}'' | ||
template: | ||
src: cloudflared.service.j2 | ||
dest: "{{ systemd_target_dir }}/{{ systemd_filename }}" | ||
- name: Start systemd service {{ systemd_filename }} | ||
systemd: | ||
name: "{{ systemd_filename }}" | ||
state: restarted | ||
enabled: yes | ||
daemon_reload: yes | ||
dest: "{{ systemd_target_dir }}/{{ systemd_filename }}@.service" |
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
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,11 +1,12 @@ | ||
[Unit] | ||
Description=cloudflared tunnel for {{ service_name }} | ||
Description=cloudflared tunnel for %I | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=cloudflared tunnel --config {{ config_dir_tunnels }}/{{ config_filename }} | ||
ExecStart=cloudflared tunnel --config {{ config_dir_tunnels }}/%i.yml | ||
User={{ systemd_user }} | ||
Group={{ systemd_group }} | ||
|
||
[Install] | ||
After=NetworkManager.service | ||
WantedBy=multi-user.target |
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,43 +1,43 @@ | ||
hostname: {{ hostname }} | ||
url: {{ url }} | ||
logfile: /var/log/cloudflared_{{ service_name }}.log | ||
hostname: {{ item.value.hostname }} | ||
url: {{ item.value.url }} | ||
logfile: /var/log/cloudflared_{{ item.key }}.log | ||
|
||
{% if lb_pool is defined %} | ||
lb-pool: {{ lb_pool }} | ||
{% if item.value.lb_pool is defined %} | ||
lb-pool: {{ item.value.lb_pool }} | ||
{% endif %} | ||
{% if autoupdate_freq is defined %} | ||
autoupdate-freq: {{ autoupdate_freq }} | ||
{% if item.value.autoupdate_freq is defined %} | ||
autoupdate-freq: {{ item.value.autoupdate_freq }} | ||
{% endif %} | ||
{% if no_autoupdate is defined %} | ||
no-autoupdate: {{ no_autoupdate }} | ||
{% if item.value.no_autoupdate is defined %} | ||
no-autoupdate: {{ item.value.no_autoupdate }} | ||
{% endif %} | ||
{% if no_tls_verify is defined %} | ||
no-tls-verify: {{ no_tls_verify }} | ||
{% if item.value.no_tls_verify is defined %} | ||
no-tls-verify: {{ item.value.no_tls_verify }} | ||
{% endif %} | ||
{% if origin_ca_pool is defined %} | ||
origin-ca-pool: {{ origin_ca_pool }} | ||
{% if item.value.origin_ca_pool is defined %} | ||
origin-ca-pool: {{ item.value.origin_ca_pool }} | ||
{% endif %} | ||
{% if origin_server_name is defined %} | ||
origin-server-name: {{ origin_server_name }} | ||
{% if item.value.origin_server_name is defined %} | ||
origin-server-name: {{ item.value.origin_server_name }} | ||
{% endif %} | ||
{% if metrics is defined %} | ||
metrics: {{ metrics }} | ||
{% if item.value.metrics is defined %} | ||
metrics: {{ item.value.metrics }} | ||
{% endif %} | ||
{% if metrics_update_freq is defined %} | ||
metrics-update-freq: {{ metrics_update_freq }} | ||
{% if item.value.metrics_update_freq is defined %} | ||
metrics-update-freq: {{ item.value.metrics_update_freq }} | ||
{% endif %} | ||
{% if tag is defined %} | ||
tag: {{ tag }} | ||
{% if item.value.tag is defined %} | ||
tag: {{ item.value.tag }} | ||
{% endif %} | ||
{% if loglevel is defined %} | ||
loglevel: {{ loglevel }} | ||
{% if item.value.loglevel is defined %} | ||
loglevel: {{ item.value.loglevel }} | ||
{% endif %} | ||
{% if proto_loglevel is defined %} | ||
proto-loglevel: {{ proto_loglevel }} | ||
{% if item.value.proto_loglevel is defined %} | ||
proto-loglevel: {{ item.value.proto_loglevel }} | ||
{% endif %} | ||
{% if retries is defined %} | ||
retries: {{ retries }} | ||
{% if item.value.retries is defined %} | ||
retries: {{ item.value.retries }} | ||
{% endif %} | ||
{% if no_chunked_encoding is defined %} | ||
no-chunked-encoding: {{ no_chunked_encoding }} | ||
{% if item.value.no_chunked_encoding is defined %} | ||
no-chunked-encoding: {{ item.value.no_chunked_encoding }} | ||
{% endif %} |
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