---
- name: Ensuring config directories exist for OVN relay containers
  vars:
    ovn_sb_db_relay_group_id: "{{ item }}"
  file:
    path: "{{ node_config_directory }}/ovn-sb-db-relay-{{ item }}"
    state: "directory"
    owner: "{{ config_owner_user }}"
    group: "{{ config_owner_group }}"
    mode: "0770"
  become: true

- name: Copying over config.json files for OVN relay services
  vars:
    # NOTE(mnasiadka): Used in the ovn_sb_relay_command template in defaults/main.yml
    ovn_sb_db_relay_group_id: "{{ item }}"
  template:
    src: "ovn-sb-db-relay.json.j2"
    dest: "{{ node_config_directory }}/ovn-sb-db-relay-{{ item }}/config.json"
    mode: "0660"
  become: true

- name: Generate config files for OVN relay services
  vars:
    # NOTE(mnasiadka): Used in the ovn_sb_relay_command template in defaults/main.yml
    ovn_sb_db_relay_group_id: "{{ item }}"
  template:
    src: "ovsdb-relay.json.j2"
    dest: "{{ node_config_directory }}/ovn-sb-db-relay-{{ item }}/ovsdb-relay.json"
    mode: "0660"
  become: true
