# vim: ft=yaml.ansible
---
- name: create privatebin volume folders
  file:
    name: "{{ services.privatebin.volume_folder }}/{{ volume }}"
    state: directory
  loop:
    - cfg
    - data
  loop_control:
    loop_var: volume

- name: upload privatebin config
  template:
    src: files/configs/privatebin-conf.php
    dest: "{{ services.privatebin.volume_folder }}/cfg/conf.php"

- name: privatebin app container
  docker_container:
    name: privatebin
    image: jgeusebroek/privatebin:{{ services.privatebin.version }}
    restart_policy: unless-stopped
    volumes:
      - "{{ services.privatebin.volume_folder }}/cfg:/privatebin/cfg"
      - "{{ services.privatebin.volume_folder }}/data:/privatebin/data"
    networks:
      - name: external_services
    env:
      VIRTUAL_HOST: "{{ services.privatebin.domain }}"
      LETSENCRYPT_HOST: "{{ services.privatebin.domain }}"
      LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}"