---

- name: create directory /etc/docker-compose/robot_proxy_v2
  file:
    dest: /etc/docker-compose/robot_proxy_v2
    state: directory
  become: yes

- name: templatize robot proxy v2 docker-compose.yml
  template:
    src=docker-compose.yml.j2
    dest=/etc/docker-compose/robot_proxy_v2/docker-compose.yml
  become: yes

# Ansible 2.2 pull flag in docker_service still doesn't work as expected if
# any version of the image isn't present on the host
# https://github.com/ansible/ansible/issues/20458
- command: docker-compose pull chdir=/etc/docker-compose/robot_proxy_v2
  name: pull robot_proxy image

- name: run robot proxy
  docker_compose:
    project_src: /etc/docker-compose/robot_proxy_v2
    pull: yes
    restarted: "{{ robot_proxy_restart }}"
    state: "{{ robot_proxy_state }}"
