---

- name: create project related directories
  file:
    path: "{{ item }}"
    state: directory
  with_items:
    - /etc/docker-compose/cobbler
    - /etc/docker-compose/cobbler/dist
    - /etc/docker-compose/cobbler/dist/image
    - /etc/docker-compose/cobbler/etc/cobbler
    - /etc/docker-compose/cobbler/isos
    - /etc/docker-compose/cobbler/var/www/html/

- name: Copy compose, dhcp.template and settings files
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
  with_items:
    - src: "docker-compose.yml"
      dest: "/etc/docker-compose/cobbler/docker-compose.yml"
    - src: "dhcp.template"
      dest: "/etc/docker-compose/cobbler/etc/cobbler/dhcp.template"
    - src: "named.template"
      dest: "/etc/docker-compose/cobbler/etc/cobbler/named.template"
    - src: "settings"
      dest: "/etc/docker-compose/cobbler/etc/cobbler/settings"
    - src: "zoox_init.sh"
      dest: "/etc/docker-compose/cobbler/var/www/html/zoox_init.sh"
    - src: "zoox_post_init.sh"
      dest: "/etc/docker-compose/cobbler/var/www/html/zoox_post_init.sh"
    - src: "trusty-sources.list"
      dest: "/etc/docker-compose/cobbler/var/www/html/trusty-sources.list"
    - src: "zoox_init_cryptsetup_initrd.sh"
      dest: "/etc/docker-compose/cobbler/var/www/html/zoox_init_cryptsetup_initrd.sh"
    - src: "zoox_init_cryptsetup_lukskey.sh"
      dest: "/etc/docker-compose/cobbler/var/www/html/zoox_init_cryptsetup_lukskey.sh"
    - src: "xorg_compute_3.conf"
      dest: "/etc/docker-compose/cobbler/var/www/html/xorg_compute_3.conf"

- name: start cobbler
  docker_service:
    project_src: /etc/docker-compose/cobbler
    state: present
