---

stage: "prodwork01"

hcloud_firewall_app_specific_stuff: False

# TODO read configuration with hetzner rest api
shared_service_network: "10.3.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: 188.34.196.240 #server in prodnso!!!
shared_service_gitea_ip: 157.90.169.198 #server in prodnso!!!
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_kube_cpl_01: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-cpl-01' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_kube_cpl_02: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-cpl-02' )
  | map(attribute='private_ip')
  | list
  | first
  | default('-') }}"
shared_service_kube_cpl_03: "{{ stage_server_infos
  | selectattr('name', 'match', stage + '-kube-cpl-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_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_cpl_01_hostname: "{{ stage }}-kube-cpl-01.{{ domain }}"
kube_cpl_02_hostname: "{{ stage }}-kube-cpl-02.{{ domain }}"
kube_cpl_03_hostname: "{{ stage }}-kube-cpl-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_gitea_hostname: "prodnso-gitea-01.{{ domain }}"
shared_service_harbor_hostname: "prodnso-harbor-01.{{ domain }}"
shared_service_kube_prometheus_hostname: "{{ stage }}-kube-prometheus.{{ domain }}"
shared_service_kube_jaeger_collector_hostname: "{{ stage }}-kube-jaeger-collector.{{ domain }}"

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_kube_cpl_01 }}",
    name: "{{ kube_cpl_01_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_cpl_02 }}",
    name: "{{ kube_cpl_02_hostname }}"
  },
  {
    ip: "{{ shared_service_gitea_ip }}",
    name: "{{ shared_service_gitea_hostname }}"
  },
  {
    ip: "{{ shared_service_kube_cpl_03 }}",
    name: "{{ kube_cpl_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 }}"
  },
]

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

# 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 }}"
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 }}"

postgres_replicator_user_password: "{{ postgres_replicator_user_password_vault }}"

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

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

kubernetes_with_awx: False
