2017-01-13 19:57:14 +01:00
|
|
|
---
|
|
|
|
- block:
|
2018-07-30 19:28:47 +02:00
|
|
|
- name: Create the sharelatex data dirs on the host when the container runs as docker
|
|
|
|
file: dest={{ sharelatex_host_data_dir }} state=directory owner=docker group=docker
|
2017-01-13 19:57:14 +01:00
|
|
|
when: docker_run_as_docker_user
|
|
|
|
|
|
|
|
- name: Create the sharelatex data dir on the host when the container runs as root
|
2018-07-30 19:28:47 +02:00
|
|
|
file: dest={{ sharelatex_host_data_dir }} state=directory
|
2017-01-13 19:57:14 +01:00
|
|
|
when: not docker_run_as_docker_user
|
|
|
|
|
|
|
|
- name: Create the sharelatex directory into the docker s user home
|
|
|
|
file: dest={{ docker_user_home }}/sharelatex state=directory owner=docker group=docker
|
|
|
|
when: docker_run_as_docker_user
|
|
|
|
|
|
|
|
- name: Install the docker env file when the container runs as docker
|
|
|
|
template: src=sharelatex-env.sh.j2 dest={{ docker_user_home }}/sharelatex/sharelatex-env.sh owner=docker group=docker
|
|
|
|
when: docker_run_as_docker_user
|
|
|
|
|
|
|
|
- name: Install the docker env file when the container runs as root
|
|
|
|
template: src=sharelatex-env.sh.j2 dest=/opt/sharelatex-env.sh
|
|
|
|
when: not docker_run_as_docker_user
|
|
|
|
|
|
|
|
- name: Start the Sharelatex docker container as docker user
|
2017-02-13 19:22:47 +01:00
|
|
|
become: True
|
|
|
|
become_user: docker
|
2018-07-30 19:28:47 +02:00
|
|
|
docker_container: name={{ sharelatex_container_name }} volumes={{ sharelatex_host_data_dir }}:{{ sharelatex_container_data_dir }} published_ports={{ sharelatex_container_public_port }}:{{ sharelatex_container_local_port }} env_file={{ docker_user_home }}/sharelatex/sharelatex-env.sh image={{ sharelatex_docker_image }} state=started keep_volumes=yes pull=yes
|
2017-01-13 19:57:14 +01:00
|
|
|
when: docker_run_as_docker_user
|
|
|
|
|
|
|
|
- name: Start the Sharelatex docker container as root
|
2017-02-13 19:22:47 +01:00
|
|
|
command: docker run -v {{ sharelatex_host_data_dir }}:{{ sharelatex_container_data_dir }} -p {{ sharelatex_container_public_port }}:{{ sharelatex_container_local_port }} --name={{ sharelatex_container_name }} --env-file /opt/sharelatex-env.sh image={{ sharelatex_docker_image }}
|
2017-01-13 19:57:14 +01:00
|
|
|
when: not docker_run_as_docker_user
|
|
|
|
|
|
|
|
when: sharelatex_install
|
|
|
|
tags: [ 'docker', 'sharelatex' ]
|