apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
namespace: openstack
patches:
- target:
    kind: OpenStackDataPlaneNodeSet
  patch: |-
    - op: replace
      path: /spec/nodes/edpm-compute-0/hostName
      value: "compute-0"
    - op: replace
      path: /spec/nodes/edpm-compute-1/hostName
      value: "compute-1"
    - op: replace
      path: /spec/nodeTemplate/ansible/ansibleVars/neutron_public_interface_name
      value: "eth1"

    - op: replace
      path: /spec/nodes/edpm-compute-0/networks/0/defaultRoute
      value: false
    - op: replace
      path: /spec/nodes/edpm-compute-1/networks/0/defaultRoute
      value: false

    - op: replace
      path: /spec/nodes/edpm-compute-1/ansible/ansibleHost
      value: >-
        192.168.122.101

    - op: replace
      path: /spec/nodes/edpm-compute-1/networks/0/fixedIP
      value: >-
        192.168.122.101

    - op: add
      path: /spec/nodeTemplate/ansible/ansibleVars/edpm_os_net_config_mappings
      value:
        net_config_data_lookup:
          edpm-compute:
            nic2: "eth1"

    - op: add
      path: /spec/nodeTemplate/ansible/ansibleVars/edpm_network_config_debug
      value: true

    - op: add
      path: /spec/env
      value: {}

    - op: add
      path: /spec/env
      value:
        - name: "ANSIBLE_VERBOSITY"
          value: "2"

    - op: replace
      path: /spec/nodeTemplate/ansible/ansibleVars/edpm_network_config_template
      value: |-
          ---
          {% set mtu_list = [ctlplane_mtu] %}
          {% for network in nodeset_networks %}
          {% set _ = mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) %}
          {%- endfor %}
          {% set min_viable_mtu = mtu_list | max %}
          network_config:
          - type: interface
            name: nic1
            use_dhcp: true
            mtu: {{ min_viable_mtu }}
          - type: ovs_bridge
            name: {{ neutron_physical_bridge_name }}
            mtu: {{ min_viable_mtu }}
            use_dhcp: false
            dns_servers: {{ ctlplane_dns_nameservers }}
            domain: {{ dns_search_domains }}
            addresses:
            - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_cidr }}
            routes: {{ ctlplane_host_routes }}
            members:
            - type: interface
              name: nic2
              mtu: {{ min_viable_mtu }}
              # force the MAC address of the bridge to this interface
              primary: true
          {% if edpm_network_config_nmstate | bool %}
              # this ovs_extra configuration fixes OSPRH-17551, but it will be not needed when FDP-1472 is resolved
              ovs_extra:
                - "set interface eth1 external-ids:ovn-egress-iface=true"
          {% endif %}
          {% for network in nodeset_networks %}
            - type: vlan
              mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
              vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
              addresses:
              - ip_netmask:
                  {{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
              routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
          {% endfor %}
          
    - op: replace
      path: /spec/nodeTemplate/ansible/ansibleUser
      value: "zuul"

    - op: replace
      path: /spec/nodeTemplate/ansible/ansibleVars/ctlplane_dns_nameservers
      value:
        - "192.168.122.10"
        - "199.204.44.24"

    - op: add
      path: /spec/nodeTemplate/ansible/ansibleVars/edpm_container_registry_insecure_registries
      value: ["38.102.83.94:5001"]

    - op: add
      path: /spec/nodeTemplate/ansible/ansibleVars/edpm_sshd_allowed_ranges
      value: ["0.0.0.0/0"]


    - op: replace
      path: /spec/nodeTemplate/ansible/ansibleVars/edpm_telemetry_enabled_exporters
      value:
        - "podman_exporter"
        - "openstack_network_exporter"
