---

- block:

  - name: create project related directories
    file:
      path: "{{ item }}"
      state: directory
    with_items:
      - /etc/docker-compose/kitt_imager
    notify:
      - restart kitt_imager

  - name: Copy compose file of kitt_imager
    template:
      src: "{{ item.src }}"
      dest: "{{ item.dest }}"
    with_items:
      - src: "docker-compose.yml"
        dest: "/etc/docker-compose/kitt_imager/docker-compose.yml"
    notify:
      - restart kitt_imager

  - name: start kitt_imager
    docker_service:
      project_src: /etc/docker-compose/kitt_imager
      state: present
    notify:
      - restart kitt_imager

  - name: Create a kitt imager restarter cron
    cron:
      name: kitt_imager
      minute: 30
      hour: 5
      user: zoox
      job: "/usr/bin/docker restart kitt_imager"
      cron_file: kitt_imager

  become: yes
