---
- name: Create the contrail namespace template file
  template:
    src: contrail-namespace.j2
    dest: /tmp/contrail-namespace.yaml
    owner: root
    mode: 0644
  run_once: True

- name: Copy the wait for pod script to master node
  template:
    src: wait_for_pod.j2
    dest: /tmp/wait_for_pod.sh
    owner: root
    mode: 0777
  run_once: True

- name: Check if the contrail-system namespace is created
  oc_project:
    state: present
    name: "contrail-system"
    node_selector: ""
  run_once: True

- name: Give privileged access to default service account of contrail-system namespace
  oc_adm_policy_user:
    user: system:serviceaccount:contrail-system:default
    resource_kind: scc
    resource_name: privileged
    state: present
  run_once: True

- name: Create Contrail registry secret
  command: "{{ openshift_client_binary }} create secret docker-registry contrail-registry-secret --docker-server={{ contrail_registry }} --docker-username={{ contrail_registry_username }} --docker-password={{ contrail_registry_password }} --docker-email=contrail@helloworld.com -n contrail-system"
  run_once: True
  when: contrail_registry_username is defined
  ignore_errors: True

- name: Enable Fabric SNAT on default project
  command: "{{ openshift_client_binary }} annotate namespace default \"opencontrail.org/ip_fabric_snat=true\" --overwrite"
