---

- name: create portainer volume folder
  file:
    name: "{{ services.portainer.volume_folder }}"
    state: directory

- name: run portainer
  docker_container:
    name: portainer
    image: portainer/portainer-ee:{{ services.portainer.version }}
    restart_policy: always
    networks:
      - name: external_services
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - "{{ services.portainer.volume_folder }}:/data"
    env:
      VIRTUAL_HOST: "{{ services.portainer.domain }}"
      VIRTUAL_PORT: "9000"
      LETSENCRYPT_HOST: "{{ services.portainer.domain }}"
      LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}"