Use froxlor correctly

This commit is contained in:
Dryusdan 2024-03-01 14:07:48 +01:00
parent bbaf313bc2
commit 64d0d104d3
3 changed files with 61 additions and 1 deletions

View File

@ -17,4 +17,5 @@ lxc_item_proxy:
remove_error_pages: True
disable_referer: False
letsencrypt: true
proxy: "http://[2a01:e0a:21a:17a7::1]:80"
upstream: "{{ upstream }}"
proxy: "http://froxlor_backend"

View File

@ -8,8 +8,58 @@
- use_froxlor
- not loop_domain in know_froxlor_domain
- name: "Get domain info"
ansible.builtin.uri:
url: "{{ froxlor_url }}/api.php"
method: "POST"
headers:
Content-Type: "application/json"
Authorization: "Basic {{ froxlor_token }}"
body: "{\"command\":\"SubDomains.get\", \"params\": {\"domainname\": \"{{ loop_domain }}\"} }"
status_code: 200
body_format: "json"
register: domain_info
delegate_to: localhost
when:
- use_froxlor is defined
- use_froxlor
- not loop_domain in know_froxlor_domain
tags:
- froxlor
- debug:
var: domain_info["json"]["data"]
verbosity: 2
when:
- use_froxlor is defined
- use_froxlor
- not loop_domain in know_froxlor_domain
tags:
- froxlor
- name: show templating results
ansible.builtin.debug:
msg: "{{ lookup('ansible.builtin.template', 'templates/vhosts/partials/froxlor_upstream.j2') }}"
when:
- use_froxlor is defined
- use_froxlor
- not loop_domain in know_froxlor_domain
tags:
- froxlor
- name: Set var
ansible.builtin.set_fact:
upstream: "{{ lookup('ansible.builtin.template', 'templates/vhosts/partials/froxlor_upstream.j2') }}"
tags:
- froxlor
when:
- use_froxlor is defined
- use_froxlor
- not loop_domain in know_froxlor_domain
- name: Set var
ansible.builtin.set_fact:
#item: "{{ lxc_item_redirect | combine( { upstream: upstream } ) }}"
item: "{{ lxc_item_redirect }}"
tags:
- froxlor

View File

@ -0,0 +1,9 @@
upstream froxlor_backend {
{% for ip in domain_info["json"]["data"]["ipsandports"] -%}
{%- if ip["ip"] is ansible.utils.ipv6 -%}
server [{{ ip["ip"]}}]:{{ ip["port"] }};
{%- else -%}
server {{ ip["ip"]}}:{{ ip["port"] }};
{% endif %}
{% endfor %}
}