---
- name: Install Bind
  package: name=bind state=present
  when: not openshift.common.is_containerized | bool

- name: Create docker build dir
  file: path=/tmp/dockerbuild state=directory
  when: openshift.common.is_containerized | bool

- name: Install dockerfile
  template:
    dest: "/tmp/dockerbuild/Dockerfile"
    src: Dockerfile
  when: openshift.common.is_containerized | bool

- name: Build Bind image
  docker_image: path="/tmp/dockerbuild" name="bind" state=present
  when: openshift.common.is_containerized | bool

- name: Install bind service file
  template:
    dest: "/etc/systemd/system/named.service"
    src: named.service.j2
  when: openshift.common.is_containerized | bool

- name: Create bind zone dir
  file: path=/var/named state=directory
  when: openshift.common.is_containerized | bool

- name: Configure Bind
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
  with_items:
    - src: openshift-cluster.zone
      dest: /var/named/openshift-cluster.zone
    - src: named.conf
      dest: /etc/named.conf
  notify: restart bind

- name: Enable Bind
  systemd:
    name: named
    state: started
    enabled: yes
    daemon_reload: yes