---

stage: "qa"

# TODO read configuration with hetzner rest api
shared_service_network: "10.1.0.0/16"
shared_service_elastic_01: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-elastic-stack-elastic-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_elastic_02: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-elastic-stack-elastic-02' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_elastic_03: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-elastic-stack-elastic-03' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_logstash_01: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-elastic-stack-logstash-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_harbor_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-harbor-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_pdns_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-pdns-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_mail_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-mail-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_pg_master_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-postgres-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_pg_slave_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-postgres-02' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_maria_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-maria-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_keycloak_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-keycloak-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_iam_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-iam-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_webdav_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-webdav-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_gitea_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-gitea-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_redis_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-redis-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_kube_master_01: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-master-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_kube_master_02: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-master-02' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_kube_master_03: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-master-03' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_kube_node_01: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-node-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_kube_node_02: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-node-02' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_kube_node_03: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-node-03' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_management_ip: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-management-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"

shared_service_kube_ip: "{{ stage_private_ingress_loadbalancer_ip | default('-') }}"

shared_service_maria_hostname: "{{ stage }}-maria-01"
shared_service_postgres_01_hostname: "{{ stage }}-postgres-01"
shared_service_elastic_stack_01_hostname: "{{ stage }}-elastic-stack-elastic-01"
shared_service_elastic_stack_02_hostname: "{{ stage }}-elastic-stack-elastic-02"
shared_service_elastic_stack_03_hostname: "{{ stage }}-elastic-stack-elastic-03"
shared_service_elastic_stack_logstash_01_hostname: "{{ stage }}-elastic-stack-logstash-01"
shared_service_elastic_stack_kibana_01_hostname: "{{ stage }}-elastic-stack-kibana-01"

kube_master_01_hostname: "{{ stage }}-kube-master-01.{{ domain }}"
kube_master_02_hostname: "{{ stage }}-kube-master-02.{{ domain }}"
kube_master_03_hostname: "{{ stage }}-kube-master-03.{{ domain }}"
kube_node_01_hostname: "{{ stage }}-kube-node-01.{{ domain }}"
kube_node_02_hostname: "{{ stage }}-kube-node-02.{{ domain }}"
kube_node_03_hostname: "{{ stage }}-kube-node-03.{{ domain }}"

shared_service_iam_hostname: "{{ stage }}-iam-01.{{ domain }}"
shared_service_mail_hostname: "{{ stage }}-mail-01.{{ domain }}"
shared_service_gitea_hostname: "{{ stage }}-gitea-01.{{ domain }}"
shared_service_redis_hostname: "{{ stage }}-redis-01.{{ domain }}"
shared_service_kube_argocd_hostname: "{{ stage }}-kube-argocd.{{ domain }}"
shared_service_kube_awx_hostname: "{{ stage }}-kube-awx.{{ domain }}"
shared_service_kube_prometheus_hostname: "{{ stage }}-kube-prometheus.{{ domain }}"
shared_service_kube_jaeger_collector_hostname: "{{ stage }}-kube-jaeger-collector.{{ domain }}"
shared_service_pdns_hostname: "{{ stage }}-pdns-01.{{ domain }}"
shared_service_webdav_hostname: "{{ stage }}-webdav-01.{{ domain }}"
shared_service_keycloak_hostname: "{{ stage }}-keycloak-01.{{ domain }}"
shared_service_harbor_hostname: "{{ stage }}-harbor-01.{{ domain }}"

management_service_connect_hostname: "{{ stage }}-management-01-connect.{{ domain }}"

keycloak_server_url: "https://{{ shared_service_keycloak_hostname }}"

shared_service_hosts: [
  {
    ip: "127.0.1.1",
    name: "{{ inventory_hostname }}"
  },
  {
    ip: "{{ shared_service_elastic_01 }}",
    name: "{{ shared_service_elastic_stack_01_hostname }}"
  },
  {
    ip: "{{ shared_service_elastic_02 }}",
    name: "{{ shared_service_elastic_stack_02_hostname }}"
  },
  {
    ip: "{{ shared_service_elastic_03 }}",
    name: "{{ shared_service_elastic_stack_03_hostname }}"
  },
  {
    ip: "{{ shared_service_logstash_01 }}",
    name: "{{ shared_service_elastic_stack_logstash_01_hostname }}"
  },
  {
    ip: "{{ shared_service_maria_ip }}",
    name: "{{ shared_service_maria_hostname }}"
  },
  {
    ip: "{{ shared_service_pg_master_ip }}",
    name: "{{ shared_service_postgres_01_hostname }}"
  },
  {
    ip: "{{ shared_service_harbor_ip }}",
    name: "{{ shared_service_harbor_hostname }}"
  },
  {
    ip: "{{ shared_service_mail_ip }}",
    name: "{{ shared_service_mail_hostname }}"
  },
  {
    ip: "{{ shared_service_keycloak_ip }}",
    name: "{{ shared_service_keycloak_hostname }}"
  },
  {
    ip: "{{ shared_service_iam_ip }}",
    name: "{{ shared_service_iam_hostname }}"
  },
  {
    ip: "{{ shared_service_webdav_ip }}",
    name: "{{ shared_service_webdav_hostname }}"
  },
  {
    ip: "{{ shared_service_gitea_ip }}",
    name: "{{ shared_service_gitea_hostname }}"
  },
  {
    ip: "{{ shared_service_redis_ip }}",
    name: "{{ shared_service_redis_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_master_01 }}",
    name: "{{ kube_master_01_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_master_02 }}",
    name: "{{ kube_master_02_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_master_03 }}",
    name: "{{ kube_master_03_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_node_01 }}",
    name: "{{ kube_node_01_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_node_02 }}",
    name: "{{ kube_node_02_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_node_03 }}",
    name: "{{ kube_node_03_hostname }}"
  },
  {
    ip: "{{ shared_service_pdns_ip }}",
    name: "{{ shared_service_pdns_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_ip }}",
    name: "{{ shared_service_kube_argocd_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_ip }}",
    name: "{{ shared_service_kube_awx_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_ip }}",
    name: "{{ shared_service_kube_prometheus_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_ip }}",
    name: "{{ shared_service_kube_jaeger_collector_hostname }}"
  },
  {
    ip: "{{ shared_service_management_ip }}",
    name: "{{ management_service_connect_hostname }}"
  }
]

# TODO read configuration with hetzner rest api
elastic_stack_network: {
  qa-elastic-stack-elastic-01: "{{ shared_service_elastic_01 }}",
  qa-elastic-stack-elastic-02: "{{ shared_service_elastic_02 }}",
  qa-elastic-stack-elastic-03: "{{ shared_service_elastic_03 }}",
}

harbor_oidc_realm: "harbor"
harbor_oidc_client_id: "harbor"
harbor_oidc_client_secret: "{{ docker_registry_oidc_client_secret_vault }}"
harbor_oidc_admin_username: "harbor-admin"
harbor_oidc_admin_password: "{{ harbor_oidc_admin_password_vault }}"


connect_image_version: "8.6"
iam_image_version: "latest"

management_oidc_realm: "management"
management_oidc_client_id: "smardigo"

smardigo_management_url: "{{ http_s }}://{{ management_service_connect_hostname }}/api/v1/scopes/{{ scope_id }}/processes/{{ process_instance_id }}/messages"

connect_jwt_enabled: true
connect_jwt_secret: "908ae14462d049d3be84964ef379c7c6"
webdav_jwt_enabled: true
webdav_jwt_secret: "5646aee6dadc4c19b15f4b65f1e6549f"
iam_jwt_enabled: true
iam_jwt_secret: "456ae14462d049d3be76439ef379c7c6"

keycloak_admin_username: "keycloak-admin"
keycloak_admin_password: "{{ keycloak_admin_password_vault }}"

# Note: all dollar signs in the hash need to be doubled for escaping.
# To create user:password pair, it's possible to use this command:
# echo $(htpasswd -nb user password) | sed -e s/\\$/\\$\\$/g
# TODO should be part of the automation (htpasswd -nb traefik-admin traefik-admin)
traefik_admin_username: "traefik-admin"
traefik_admin_password: "{{ traefik_admin_password_vault }}"

grafana_admin_username: "grafana-admin"
grafana_admin_password: "{{ grafana_admin_password_vault }}"
grafana_user_smardigo_login: "smardigo"
grafana_user_smardigo_password: "{{ grafana_user_smardigo_password_vault }}"
grafana_signing_secret: "{{ grafana_signing_secret_vault }}"

pgadmin4_admin_username: "{{ pgadmin4_admin_email }}"
pgadmin4_admin_password: "{{ pgadmin4_admin_password_vault }}"

management_admin_username: "management-admin"
management_admin_password: "{{ management_admin_password_vault }}"
management_realm_admin_username: "management-realm-admin"
management_realm_admin_password: "{{ management_realm_admin_password_vault }}"

harbor_admin_username: "{{ harbor_admin_username_vault }}"
harbor_admin_password: "{{ harbor_admin_password_vault }}"
harbor_postgresql_password: "{{ harbor_postgresql_password_vault }}"

harbor_username: "{{ docker_registry_username_vault }}"
harbor_token: "{{ docker_registry_token_vault }}"

elastic_admin_username: "{{ elastic_admin_username_vault }}"
elastic_admin_password: "{{ elastic_admin_password_vault }}"

elastic_ilm_cold_min_age_threshold: 3d
elastic_ilm_delete_min_age_threshold: 7d

postgres_replicator_user_password: "{{ postgres_replicator_user_password_vault }}"

mysql_root_username: "{{ mysql_root_username_vault }}"
mysql_root_password: "{{ mysql_root_password_vault }}"

gitea_admin_username: "gitea-admin"
gitea_admin_password: "{{ gitea_admin_password_vault }}"
gitea_realm_admin_username: "gitea-realm-admin"
gitea_realm_admin_password: "gitea-realm-admin"

argocd_admin_username: "argocd-admin"
argocd_admin_password: "{{ argocd_admin_password_vault }}"
argo_keycloak_client_secret: "{{ argo_keycloak_client_secret_vault }}"
argocd_server_admin_password: "{{ argocd_server_admin_password_vault }}"

awx_admin_username: "awx-admin"
awx_admin_password: "{{ awx_admin_password_vault }}"

netgo_msteams_hook_cd: "{{ netgo_msteams_hook_cd_vault }}"
netgo_msteams_hook_alerting: "{{ netgo_msteams_hook_alerting_vault }}"

management_oidc_client_secret: "{{ management_oidc_client_secret_vault }}"

# smardigo automation QA gpg key
# https://git.dev-at.de/smardigo-hetzner/communication-keys/
# push mirror: https://qa-gitea-01.smardigo.digital/gitea-admin/communication-keys/
gpg_key_smardigo_automation__private: '{{ gpg_key_smardigo_automation__private__vault }}'

iam_opentracing_jaeger_enabled: true
iam_opentracing_jaeger_http_sender_url: "http://{{ shared_service_kube_jaeger_collector_hostname }}/api/traces"
webdav_opentracing_jaeger_enabled: true
webdav_opentracing_jaeger_http_sender_url: "http://{{ shared_service_kube_jaeger_collector_hostname }}/api/traces"
connect_opentracing_jaeger_enabled: true
connect_opentracing_jaeger_http_sender_url: "http://{{ shared_service_kube_jaeger_collector_hostname }}/api/traces"
