mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Fail safed more parts of the code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
var primary = "{{ primary_domain }}";
|
||||
var allowedOrigin = "https://{{ domains | get_domain('portfolio') }}";
|
||||
var allowedOrigin = "https://{{ domains | get_domain('web-app-port-ui') }}";
|
||||
|
||||
function notifyParent() {
|
||||
try {
|
||||
|
@@ -17,7 +17,7 @@
|
||||
name: srv-web-7-6-composer
|
||||
vars:
|
||||
domain: "{{domains.matrix.synapse}}"
|
||||
http_port: "{{ports.localhost.http.synapse}}"
|
||||
http_port: "{{ports.localhost.http.matrix_synapse}}"
|
||||
|
||||
- name: create {{well_known_directory}}
|
||||
file:
|
||||
@@ -36,7 +36,7 @@
|
||||
dest: "{{nginx.directories.http.servers}}{{domains.matrix.synapse}}.conf"
|
||||
vars:
|
||||
domain: "{{domains.matrix.synapse}}" # Didn't work in the past. May it works now. This does not seem to work @todo Check how to solve without declaring set_fact, seems a bug at templates
|
||||
http_port: "{{ports.localhost.http.synapse}}"
|
||||
http_port: "{{ports.localhost.http.matrix_synapse}}"
|
||||
notify: restart nginx
|
||||
|
||||
- name: "include role srv-proxy-6-6-domain for {{application_id}}"
|
||||
@@ -44,7 +44,7 @@
|
||||
name: srv-proxy-6-6-domain
|
||||
vars:
|
||||
domain: "{{domains.matrix.element}}"
|
||||
http_port: "{{ports.localhost.http.element}}"
|
||||
http_port: "{{ports.localhost.http.matrix_element}}"
|
||||
|
||||
- name: include create-and-seed-database.yml for multiple bridges
|
||||
include_tasks: create-and-seed-database.yml
|
||||
|
@@ -17,7 +17,7 @@
|
||||
- SYNAPSE_SERVER_NAME={{domains.matrix.synapse}}
|
||||
- SYNAPSE_REPORT_STATS=no
|
||||
ports:
|
||||
- "127.0.0.1:{{ports.localhost.http.synapse}}:{{ container_port }}"
|
||||
- "127.0.0.1:{{ports.localhost.http.matrix_synapse}}:{{ container_port }}"
|
||||
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
|
||||
{% if bridges | length > 0 %}
|
||||
{% for item in bridges %}
|
||||
@@ -36,7 +36,7 @@
|
||||
volumes:
|
||||
- ./element-config.json:/app/config.json
|
||||
ports:
|
||||
- "127.0.0.1:{{ports.localhost.http.element}}:{{ container_port }}"
|
||||
- "127.0.0.1:{{ports.localhost.http.matrix_element}}:{{ container_port }}"
|
||||
{% include 'roles/docker-container/templates/healthcheck/wget.yml.j2' %}
|
||||
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
||||
|
||||
|
@@ -2,7 +2,7 @@ server {
|
||||
{# Somehow .j2 doesn't interpretate the passed variable right. For this reasons this redeclaration is necessary #}
|
||||
{# Could be that this is related to the set_fact use #}
|
||||
{% set domain = domains.matrix.synapse %}
|
||||
{% set http_port = ports.localhost.http.synapse %}
|
||||
{% set http_port = ports.localhost.http.matrix_synapse %}
|
||||
|
||||
server_name {{domains.matrix.synapse}};
|
||||
{% include 'roles/srv-web-7-7-letsencrypt/templates/ssl_header.j2' %}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# PortWebUI
|
||||
# PortUI
|
||||
|
||||
## Description
|
||||
|
||||
|
@@ -16,13 +16,13 @@ class LookupModule(LookupBase):
|
||||
This lookup iterates over all roles whose folder name starts with 'web-app-'
|
||||
and generates a list of dictionaries (cards). For each role, it:
|
||||
|
||||
- Extracts the application_id (everything after "web-app-")
|
||||
- Reads application_id from the role's vars/main.yml
|
||||
- Reads the title from the role's README.md (the first H1 line)
|
||||
- Retrieves the description from galaxy_info.description in meta/main.yml
|
||||
- Retrieves the icon class from galaxy_info.logo.class
|
||||
- Retrieves the tags from galaxy_info.galaxy_tags
|
||||
- Builds the URL using the 'domains' variable (e.g. domains | get_domain(application_id))
|
||||
- Sets the iframe flag from applications[application_id].features.iframe
|
||||
- Builds the URL using the 'domains' variable
|
||||
- Sets the iframe flag from applications[application_id].features.portfolio_iframe
|
||||
|
||||
Only cards whose application_id is included in the variable group_names are returned.
|
||||
"""
|
||||
@@ -40,11 +40,22 @@ class LookupModule(LookupBase):
|
||||
role_basename = os.path.basename(role_dir)
|
||||
|
||||
# Skip roles not starting with "web-app-"
|
||||
if not role_basename.startswith("web-app-"):
|
||||
if not role_basename.startswith("web-app-"): # Ensure prefix
|
||||
continue
|
||||
|
||||
# Extract application_id from role name
|
||||
application_id = role_basename[len("web-app-"):]
|
||||
# Load application_id from role's vars/main.yml
|
||||
vars_path = os.path.join(role_dir, "vars", "main.yml")
|
||||
try:
|
||||
if not os.path.isfile(vars_path):
|
||||
raise AnsibleError(f"Vars file not found for role '{role_basename}': {vars_path}")
|
||||
with open(vars_path, "r", encoding="utf-8") as vf:
|
||||
vars_content = vf.read()
|
||||
vars_data = yaml.safe_load(vars_content) or {}
|
||||
application_id = vars_data.get("application_id")
|
||||
if not application_id:
|
||||
raise AnsibleError(f"Key 'application_id' not found in {vars_path}")
|
||||
except Exception as e:
|
||||
raise AnsibleError(f"Error getting application_id for role '{role_basename}': {e}")
|
||||
|
||||
# Skip roles not listed in group_names
|
||||
if application_id not in group_names:
|
||||
@@ -65,25 +76,24 @@ class LookupModule(LookupBase):
|
||||
title_match = re.search(r'^#\s+(.*)$', readme_content, re.MULTILINE)
|
||||
title = title_match.group(1).strip() if title_match else application_id
|
||||
except Exception as e:
|
||||
raise AnsibleError("Error reading '{}': {}".format(readme_path, str(e)))
|
||||
raise AnsibleError(f"Error reading '{readme_path}': {e}")
|
||||
|
||||
# Extract metadata from meta/main.yml
|
||||
try:
|
||||
with open(meta_path, "r", encoding="utf-8") as f:
|
||||
meta_data = yaml.safe_load(f)
|
||||
meta_data = yaml.safe_load(f) or {}
|
||||
|
||||
galaxy_info = meta_data.get("galaxy_info", {})
|
||||
|
||||
# If display is set to False ignore it
|
||||
if not galaxy_info.get("display", True):
|
||||
continue
|
||||
|
||||
|
||||
description = galaxy_info.get("description", "")
|
||||
logo = galaxy_info.get("logo", {})
|
||||
icon_class = logo.get("class", "fa-solid fa-cube")
|
||||
tags = galaxy_info.get("galaxy_tags", [])
|
||||
except Exception as e:
|
||||
raise AnsibleError("Error reading '{}': {}".format(meta_path, str(e)))
|
||||
raise AnsibleError(f"Error reading '{meta_path}': {e}")
|
||||
|
||||
# Retrieve domains and applications from the variables
|
||||
domains = variables.get("domains", {})
|
||||
@@ -94,7 +104,7 @@ class LookupModule(LookupBase):
|
||||
domain_url = domain_url[0]
|
||||
elif isinstance(domain_url, dict):
|
||||
domain_url = next(iter(domain_url.values()))
|
||||
|
||||
|
||||
# Construct the URL using the domain_url if available.
|
||||
url = "https://" + domain_url if domain_url else ""
|
||||
|
||||
@@ -107,7 +117,7 @@ class LookupModule(LookupBase):
|
||||
"title": title,
|
||||
"text": description,
|
||||
"url": url,
|
||||
"link_text": "Explore {}".format(title),
|
||||
"link_text": f"Explore {title}",
|
||||
"iframe": iframe,
|
||||
"tags": tags,
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Kevin Veen-Birkenbach"
|
||||
description: "Portfolio to showcase your projects and creative work with a focus on user experience and easy customization. 🚀"
|
||||
description: "PortUI provides CyMaIS users with a unified web interface to easily access all their applications in one place"
|
||||
license: "CyMaIS NonCommercial License (CNCL)"
|
||||
license_url: "https://s.veen.world/cncl"
|
||||
company: |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
application_id: "web-app-port-ui"
|
||||
docker_repository_address: "https://github.com/kevinveenbirkenbach/port-web-ui"
|
||||
docker_repository_address: "https://github.com/kevinveenbirkenbach/port-ui"
|
||||
config_inventory_path: "{{ inventory_dir }}/files/{{ inventory_hostname }}/docker/web-app-port-ui/config.yaml.j2"
|
||||
docker_repository: true
|
Reference in New Issue
Block a user