---

- name: stat the expected ovn-kubernetes directory
  stat:
    path: "{{ ansible_env.GOPATH }}/src/github.com/ovn-org/ovn-kubernetes"
  register: dir_stat

- name: ensure cni bin directory is present
  file: path=/opt/cni/bin state=directory

- name: expect ovn-kubernetes to be cloned already
  fail:
    msg: "Expected ovn-kubernetes to be cloned at {{ ansible_env.GOPATH }}/src/github.com/ovn-org/ovn-kubernetes but it wasn't!"
  when: not dir_stat.stat.exists

- name: install ovn-kubernetes tools
  make:
    target: install.tools
    chdir: "{{ ansible_env.GOPATH }}/src/github.com/ovn-org/ovn-kubernetes/go-controller"

- name: build ovn-kubernetes
  make:
    chdir: "{{ ansible_env.GOPATH }}/src/github.com/ovn-org/ovn-kubernetes/go-controller"

- name: install ovn-kubernetes
  make:
    target: install
    chdir: "{{ ansible_env.GOPATH }}/src/github.com/ovn-org/ovn-kubernetes/go-controller"

#- name: install ovn-kubernetes systemd files
#  make:
#    target: install.systemd
#    chdir: "{{ ansible_env.GOPATH }}/src/github.com/ovn-org/ovn-kubernetes/go-controller"
#  when: ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS'
#
#- name: install ovn-kubernetes config
#  make:
#    target: install.config
#    chdir: "{{ ansible_env.GOPATH }}/src/github.com/ovn-org/ovn-kubernetes"
