---
openshift_client_binary: "{{ (openshift_is_atomic | bool) | ternary('/usr/local/bin/oc', 'oc') }}"

system_images_registry_dict:
  openshift-enterprise: "registry.redhat.io"
  origin: "quay.io"
system_images_registry: "{{ system_images_registry_dict[openshift_deployment_type | default('origin')] }}"

l_default_registry_url_dict:
  origin: 'quay.io/openshift/origin-${component}:${version}'
  openshift-enterprise: 'registry.redhat.io/openshift3/ose-${component}:${version}'
openshift_facts_default_registry_url: "{{ l_default_registry_url_dict[openshift_deployment_type] }}"

# oreg_url is defined by user input
# Example:
# oreg_url: registry.company.com:443/test/ose3/ose-${component}:${version}
openshift_facts_registry_url: "{{ oreg_url | default(openshift_facts_default_registry_url) }}"
openshift_facts_registry_host: "{{ openshift_facts_registry_url.split('/')[0] }}"  # From example: "registry.company.com:443"
openshift_facts_registry_image: "{{ openshift_facts_registry_url | regex_replace('.*?/(.*)$', '\\1') }}"  # From example: "test/ose3/ose-${component}:${version}"

l_registry_test_image_dict:
  openshift-enterprise: "{{ openshift_facts_registry_image | regex_replace('ose-\\${component}:\\${version}', 'ose-pod:' ~ openshift_image_tag) }}"
  origin: 'openshift/origin'
openshift_facts_registry_test_image: "{{ l_registry_test_image_dict[openshift_deployment_type] }}"

# Used to define a list of registry credentials
# ex openshift_additional_registry_credentials=[{'host':'registry.redhat.io','user':'bob','password':'redhat'},{'host':'registry.connect.redhat.com','user':'alice','password':'redhat','test_login':False}]
openshift_additional_registry_credentials: []

l_default_registry_image: "{{ openshift_facts_default_registry_url | regex_replace('.*?/(.*)$', '\\1') }}"
l_default_registry_test_image_dict:
  openshift-enterprise: "{{ l_default_registry_image | regex_replace('ose-\\${component}:\\${version}', 'ose-pod:' ~ openshift_image_tag) }}"
  origin: 'openshift/origin'
openshift_facts_default_registry_test_image: "{{ l_default_registry_test_image_dict[openshift_deployment_type] }}"

l_http_proxy: "{{ 'HTTP_PROXY=' ~ openshift.common.http_proxy if openshift.common.http_proxy is defined and openshift.common.http_proxy != '' else ''}}"
l_https_proxy: "{{ 'HTTPS_PROXY=' ~ openshift.common.https_proxy if openshift.common.https_proxy is defined and openshift.common.https_proxy != '' else ''}}"
l_no_proxy: "{{ 'NO_PROXY=' ~ openshift.common.no_proxy if openshift.common.no_proxy is defined and openshift.common.no_proxy != '' else ''}}"
openshift_facts_proxy_vars: "{{ l_http_proxy }} {{ l_https_proxy }} {{ l_no_proxy }}"

openshift_facts_versioned_registry_url: "{{ openshift_facts_registry_url | regex_replace('${version}' | regex_escape, openshift_image_tag | default('${version}')) }}"
# not sure why this one is more complicated than other images
openshift_cli_image: "{{ (system_images_registry == 'docker') | ternary(osn_image, (osn_image.split('/')|length==2) | ternary(system_images_registry + '/' + osn_image, osn_image)) }}"
system_openshift_cli_image: "{{ (system_images_registry == 'docker') | ternary('docker:' + openshift_cli_image, openshift_cli_image) }}"
osn_image: "{{ openshift_facts_versioned_registry_url | regex_replace('${component}' | regex_escape, 'node') }}"
openshift_facts_pod_image: "{{ openshift_facts_versioned_registry_url | regex_replace('${component}' | regex_escape, 'pod') }}"
openshift_facts_control_plane_image: "{{ openshift_facts_versioned_registry_url | regex_replace('${component}' | regex_escape, 'control-plane') }}"

repoquery_cmd: "{{ (ansible_pkg_mgr == 'dnf') | ternary('dnf repoquery --latest-limit 1 -d 0', 'repoquery --plugins --setopt=showdupesfromrepos=0') }}"
repoquery_installed: "{{ (ansible_pkg_mgr == 'dnf') | ternary('dnf repoquery --latest-limit 1 -d 0 --disableexcludes=all --installed', 'repoquery --plugins --installed') }}"

openshift_use_crio: False
openshift_use_crio_only: False
openshift_crio_enable_docker_gc: False
openshift_crio_var_sock: "/var/run/crio/crio.sock"
openshift_crio_pause_image: "{{ openshift_facts_pod_image }}"
openshift_container_cli: "{{ openshift_use_crio | bool | ternary('crictl', 'docker') }}"
openshift_crio_docker_gc_node_selector:
  runtime: 'cri-o'

openshift_master_default_subdomain: "router.default.svc.cluster.local"

openshift_portal_net: "{{ openshift_master_portal_net | default(None) }}"
openshift_cluster_network_cidr: "{{ osm_cluster_network_cidr | default('10.128.0.0/14') }}"
openshift_host_subnet_length: "{{ osm_host_subnet_length | default('9') }}"

openshift_hosted_etcd_storage_nfs_directory: '/exports'
openshift_hosted_etcd_storage_nfs_options: '*(rw,root_squash)'
openshift_hosted_etcd_storage_volume_name: 'etcd'
openshift_hosted_etcd_storage_volume_size: '1Gi'
openshift_hosted_etcd_storage_create_pv: True
openshift_hosted_etcd_storage_create_pvc: False
openshift_hosted_etcd_storage_access_modes:
  - 'ReadWriteOnce'

openshift_hosted_registry_namespace: 'default'
openshift_hosted_registry_storage_volume_name: 'registry'
openshift_hosted_registry_storage_volume_size: '5Gi'
openshift_hosted_registry_storage_create_pv: True
openshift_hosted_registry_storage_create_pvc: True
openshift_hosted_registry_storage_nfs_directory: '/exports'
openshift_hosted_registry_storage_nfs_options: '*(rw,root_squash)'
openshift_hosted_registry_storage_glusterfs_endpoints: 'glusterfs-registry-endpoints'
openshift_hosted_registry_storage_glusterfs_path: glusterfs-registry-volume
openshift_hosted_registry_storage_glusterfs_readOnly: False
openshift_hosted_registry_storage_glusterfs_swap: False
openshift_hosted_registry_storage_glusterfs_swapcopy: True
openshift_hosted_registry_storage_glusterfs_ips: []
openshift_hosted_registry_storage_hostpath_path: /var/lib/openshift_volumes
# Default to ReadWriteOnce if using hostpath, else default to ReadWriteMany
openshift_hosted_registry_storage_access_modes:
  - "{{ (openshift_hosted_registry_storage_kind | default(none) == 'hostpath') | ternary('ReadWriteOnce', 'ReadWriteMany') }}"

openshift_hosted_registry_glusterfs_namespace: "{{ openshift_hosted_registry_namespace }}"
openshift_hosted_registry_glusterfs_storage_kind: 'glusterfs'
openshift_hosted_registry_glusterfs_storage_volume_name: "{{ openshift_hosted_registry_storage_volume_name }}-glusterfs"
openshift_hosted_registry_glusterfs_storage_volume_size: "{{ openshift_hosted_registry_storage_volume_size }}"
openshift_hosted_registry_glusterfs_storage_create_pv: False
openshift_hosted_registry_glusterfs_storage_create_pvc: False
openshift_hosted_registry_glusterfs_storage_glusterfs_endpoints: "{{ openshift_hosted_registry_storage_glusterfs_endpoints }}"
openshift_hosted_registry_glusterfs_storage_glusterfs_path: "{{ openshift_hosted_registry_storage_glusterfs_path }}"
openshift_hosted_registry_glusterfs_storage_glusterfs_readOnly: "{{ openshift_hosted_registry_storage_glusterfs_readOnly }}"
openshift_hosted_registry_glusterfs_storage_glusterfs_ips: "{{ openshift_hosted_registry_storage_glusterfs_ips }}"
openshift_hosted_registry_glusterfs_storage_access_modes:
  - 'ReadWriteMany'

openshift_logging_storage_nfs_directory: '/exports'
openshift_logging_storage_nfs_options: '*(rw,root_squash)'
openshift_logging_storage_volume_name: 'logging-es'
openshift_logging_storage_create_pv: True
openshift_logging_storage_create_pvc: False
openshift_logging_storage_access_modes:
  - ['ReadWriteOnce']

openshift_loggingops_storage_volume_name: 'logging-es-ops'
openshift_loggingops_storage_volume_size: '10Gi'
openshift_loggingops_storage_create_pv: True
openshift_loggingops_storage_create_pvc: False
openshift_loggingops_storage_nfs_directory: '/exports'
openshift_loggingops_storage_nfs_options: '*(rw,root_squash)'
openshift_loggingops_storage_access_modes:
  - 'ReadWriteOnce'

openshift_metrics_storage_volume_name: 'metrics'
openshift_metrics_storage_volume_size: '10Gi'
openshift_metrics_storage_create_pv: True
openshift_metrics_storage_create_pvc: False
openshift_metrics_storage_nfs_directory: '/exports'
openshift_metrics_storage_nfs_options: '*(rw,root_squash)'
openshift_metrics_storage_access_modes:
  - 'ReadWriteOnce'

openshift_service_type_dict:
  origin: origin
  openshift-enterprise: atomic-openshift
openshift_service_type: "{{ openshift_service_type_dict[openshift_deployment_type] }}"

openshift_master_api_port: "8443"
openshift_ca_host: "{{ groups.oo_first_master.0 }}"
openshift_use_openshift_sdn: true
openshift_sdn_vxlan_port: "4789"
os_sdn_network_plugin_name: "redhat/openshift-ovs-subnet"

openshift_node_groups:
  - name: node-config-master
    labels:
      - 'node-role.kubernetes.io/master=true'
    edits: []
  - name: node-config-master-crio
    labels:
      - 'node-role.kubernetes.io/master=true'
      - "{{ openshift_crio_docker_gc_node_selector | lib_utils_oo_dict_to_keqv_list | join(',') }}"
    edits: "{{ openshift_node_group_edits_crio }}"
  - name: node-config-infra
    labels:
      - 'node-role.kubernetes.io/infra=true'
    edits: []
  - name: node-config-infra-crio
    labels:
      - 'node-role.kubernetes.io/infra=true'
      - "{{ openshift_crio_docker_gc_node_selector | lib_utils_oo_dict_to_keqv_list | join(',') }}"
    edits: "{{ openshift_node_group_edits_crio }}"
  - name: node-config-compute
    labels:
      - 'node-role.kubernetes.io/compute=true'
    edits: []
  - name: node-config-compute-crio
    labels:
      - 'node-role.kubernetes.io/compute=true'
      - "{{ openshift_crio_docker_gc_node_selector | lib_utils_oo_dict_to_keqv_list | join(',') }}"
    edits: "{{ openshift_node_group_edits_crio }}"
  - name: node-config-master-infra
    labels:
      - 'node-role.kubernetes.io/master=true'
      - 'node-role.kubernetes.io/infra=true'
    edits: []
  - name: node-config-master-infra-crio
    labels:
      - 'node-role.kubernetes.io/master=true'
      - 'node-role.kubernetes.io/infra=true'
      - "{{ openshift_crio_docker_gc_node_selector | lib_utils_oo_dict_to_keqv_list | join(',') }}"
    edits: "{{ openshift_node_group_edits_crio }}"
  - name: node-config-all-in-one
    labels:
      - 'node-role.kubernetes.io/master=true'
      - 'node-role.kubernetes.io/infra=true'
      - 'node-role.kubernetes.io/compute=true'
    edits: []
  - name: node-config-all-in-one-crio
    labels:
      - 'node-role.kubernetes.io/master=true'
      - 'node-role.kubernetes.io/infra=true'
      - 'node-role.kubernetes.io/compute=true'
      - "{{ openshift_crio_docker_gc_node_selector | lib_utils_oo_dict_to_keqv_list | join(',') }}"
    edits: "{{ openshift_node_group_edits_crio }}"

openshift_node_group_edits_crio:
  - key: kubeletArguments.container-runtime
    value:
      - "remote"
  - key: kubeletArguments.container-runtime-endpoint
    value:
      - "{{ openshift_crio_var_sock }}"
  - key: kubeletArguments.image-service-endpoint
    value:
      - "{{ openshift_crio_var_sock }}"
  - key: kubeletArguments.runtime-request-timeout
    value:
      - "10m"

openshift_master_manage_htpasswd: True
