ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit f871fd070c28114e1842d53f3dd4abe0af1b83ad
parent e15a6bb5b2c6eb25810626ddc6848f65a0a44b8e
Author: Leah Thein <leah@toaster.fritz.box>
Date: Thu, 3 Dec 2020 20:00:02 +0100

frp: support for frpc
8 files changed, 107 insertions(+), 49 deletions(-)
A
roles/frp/tasks/frpc.yml
|
20
++++++++++++++++++++
A
roles/frp/tasks/frps.yml
|
37
+++++++++++++++++++++++++++++++++++++
A
roles/frp/tasks/main.yml
|
14
++++++++++++++
A
roles/frp/templates/frpc.conf.j2
|
34
++++++++++++++++++++++++++++++++++
R
roles/frps/templates/frps-vhost.conf.j2 -> roles/frp/templates/frps-vhost.conf.j2
|
0
A
roles/frp/templates/frps.confd.j2
|
2
++
D
roles/frps/tasks/main.yml
|
47
-----------------------------------------------
D
roles/frps/templates/frps.confd
|
2
--
diff --git a/roles/frp/tasks/frpc.yml b/roles/frp/tasks/frpc.yml
@@ -0,0 +1,20 @@
+---
+
+- copy:
+   content: '# Configuration for /etc/init.d/frpc\nfrps_opts="-c /etc/frpc.ini"'
+   dest: /etc/conf.d/frpc
+   mode: 0644
+
+- name: create config for frpc
+  template:
+    src: frpc.conf.j2
+    dest: /etc/frpc.ini
+    owner: frpc
+    group: frpc
+    mode: 0644
+
+- name: "Restart and enable service: frpc"
+  service:
+    name: frpc
+    state: restarted
+    enabled: yes
diff --git a/roles/frp/tasks/frps.yml b/roles/frp/tasks/frps.yml
@@ -0,0 +1,37 @@
+---
+
+- name: Copy http(s) firewall-rule to destination host
+  copy:
+    src: config-files/awall/frps.json
+    dest: /etc/awall/optional/frps.json
+    validate: jq '.' %s
+
+- name: "Enable firewall-rule for: frps"
+  awall:
+   name: frps
+   state: enabled
+   activate: yes
+
+- template:
+   src: frps.confd.j2
+   dest: /etc/conf.d/frps
+   mode: 0644
+
+- name: copy nginx-vhost for frps to destination host 
+  template: 
+    src: frps-vhost.conf.j2
+    dest: /etc/nginx/conf.d/frps.conf
+    mode: 0644
+    owner: nginx
+    group: nginx
+
+- name: "Restart and enable service: frps"
+  service:
+    name: frps
+    state: restarted
+    enabled: yes
+
+- name: "Restart and enable service: nginx"
+  service:
+    name: nginx
+    state: restarted
diff --git a/roles/frp/tasks/main.yml b/roles/frp/tasks/main.yml
@@ -0,0 +1,13 @@
+---
+
+- name: Install frp
+  apk:
+   name: frp
+   state: present
+   update_cache: yes
+
+- include: frps.yml
+  when: frps is defined
+
+- include: frpc.yml
+  when: frpc is defined+
\ No newline at end of file
diff --git a/roles/frp/templates/frpc.conf.j2 b/roles/frp/templates/frpc.conf.j2
@@ -0,0 +1,33 @@
+[common]
+server_addr = {{ frpc.serverAddress }}
+server_port = {{ frpc.serverPort }}
+token       = {{ frpc.token }}
+{% if frpc.dashboard is true %}
+dashboard_port = {{ frpc.dashboard_port }}
+dashboard_user = {{ frpc.dashboard_user }}
+dashboard_pwd  = {{ frpc.dashboard_pwd }}
+{% endif %}
+
+{% for tunnel in frpc.tunnels %}
+[{{ tunnel.name }}]
+type = {{ tunnel.type }}
+{% if tunnel.local_ip is defined %}
+local_ip = {{ tunnel.local_ip }}
+{% endif %}
+{% if tunnel.local_port is defined %}
+local_port = {{ tunnel.local_port }}
+{% endif %}
+{% if tunnel.remote_port is defined %}
+remote_port = {{ tunnel.remote_port }}
+{% endif %}
+{% if tunnel.custom_domains is defined %}
+custom_domains = {{ tunnel.custom_domains }}
+{% endif %}
+{% if tunnel.subdomain is defined %}
+subdomain = {{ tunnel.subdomain }}
+{% endif %}
+{% if tunnel.locations is defined %}
+locations = {{ tunnel.locations }}
+{% endif %}
+
+{% endfor %}+
\ No newline at end of file
diff --git a/roles/frps/templates/frps-vhost.conf.j2 b/roles/frp/templates/frps-vhost.conf.j2
diff --git a/roles/frp/templates/frps.confd.j2 b/roles/frp/templates/frps.confd.j2
@@ -0,0 +1,2 @@
+# Configuration for /etc/init.d/frps
+frps_opts="--token={{frps.token}} --bind_port={{frps.port}} --subdomain_host={{frps.vhost_domain}} --vhost_http_port={{frps.vhost_port}}"
diff --git a/roles/frps/tasks/main.yml b/roles/frps/tasks/main.yml
@@ -1,47 +0,0 @@
----
-
-- name: Install frp
-  apk:
-   name: frp
-   state: present
-   update_cache: yes
-
-- name: Copy http(s) firewall-rule to destination host
-  copy:
-    src: config-files/awall/frps.json
-    dest: /etc/awall/optional/frps.json
-    validate: jq '.' %s
-
-- awall:
-   name: frps
-   state: enabled
-   activate: yes
-
-- template:
-   src: frps.confd
-   dest: /etc/conf.d/frps
-   mode: 0644
-
-- service:
-   name: frps
-   enabled: yes
-   state: restarted
-
-- name: copy nginx-vhost for frps to destination host 
-  template: 
-    src: frps-vhost.conf.j2
-    dest: /etc/nginx/conf.d/frps.conf
-    mode: 0644
-    owner: nginx
-    group: nginx
-
-- name: restart frps
-  service:
-    name: frps
-    state: restarted
-    enabled: yes
-
-- name: restart nginx
-  service:
-    name: nginx
-    state: restarted
diff --git a/roles/frps/templates/frps.confd b/roles/frps/templates/frps.confd
@@ -1,2 +0,0 @@
-# Configuration for /etc/init.d/chartsrv
-frps_opts="--token={{frps.token}} --bind_port={{frps.port}} --subdomain_host={{frps.vhost_domain}} --vhost_http_port={{frps.vhost_port}}"