diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index 4012ed1..5729b12 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -23,6 +23,25 @@ You can also add your custom configurations to the ``etc/`` folder to stay away $ vim etc/custom-emu.yml $ ln -s etc/custom-emu.yml custom.yml +Use Conda to build identical environments +----------------------------------------- + +You can use Conda specification files to build identical environments_. +The WPS service needs to have a specification file, ``spec-file.txt``, in its top level folder. +You can set the following option in your ``custom.yml``:: + + conda_env_use_spec: true + +See an example in ``etc/sample-emu-with-conda-spec.yml``. + +.. warning:: This is option is currently enabled for `all` configured WPS services. + +.. note:: Conda spec files will work only on a specifc OS, in our case Linux. + + +.. _`environments`: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#building-identical-conda-environments + + Use external PostgreSQL Database -------------------------------- diff --git a/etc/sample-emu-with-conda-spec.yml b/etc/sample-emu-with-conda-spec.yml new file mode 100644 index 0000000..55855c4 --- /dev/null +++ b/etc/sample-emu-with-conda-spec.yml @@ -0,0 +1,10 @@ +--- +# Conda spec +conda_env_use_spec: true +# Configuration for Emu WPS +wps_services: + - name: emu + # repo: https://github.com/bird-house/emu.git + # version: master + hostname: localhost + port: 5000 diff --git a/etc/sample-vagrant.yml b/etc/sample-vagrant.yml index 645a4ec..f27604d 100644 --- a/etc/sample-vagrant.yml +++ b/etc/sample-vagrant.yml @@ -5,6 +5,8 @@ wps_enable_https: false fs_enabled: false # fs_host: "{{ server_name }}" # fs_port: 5001 +# Conda spec +# conda_env_use_spec: false # Configuration for Emu WPS wps_services: - name: emu diff --git a/roles/pywps/tasks/conda.yml b/roles/pywps/tasks/conda.yml index 8364318..bb581a5 100644 --- a/roles/pywps/tasks/conda.yml +++ b/roles/pywps/tasks/conda.yml @@ -4,8 +4,8 @@ args: chdir: "{{ src_dir }}/{{ item.name }}" with_items: "{{ wps_services }}" - when: git.changed - register: conda + when: not conda_env_use_spec + register: conda_env tags: - pywps - conda @@ -13,7 +13,25 @@ - name: Install additional Conda packages. command: "{{ conda_location }}/bin/conda install -y -p {{ conda_envs_dir}}/{{ item.name }} gunicorn psycopg2" with_items: "{{ wps_services }}" - when: conda.changed + when: conda_env.changed + tags: + - pywps + - conda + +- name: Remove Conda environment. + command: "{{ conda_location }}/bin/conda env remove -q -y -p {{ conda_envs_dir}}/{{ item.name }}" + with_items: "{{ wps_services }}" + when: conda_env_use_spec + tags: + - pywps + - conda + +- name: Create Conda environment from spec-file.txt file. + command: "{{ conda_location }}/bin/conda create --file {{ conda_env_spec_file }} -p {{ conda_envs_dir}}/{{ item.name }}" + args: + chdir: "{{ src_dir }}/{{ item.name }}" + with_items: "{{ wps_services }}" + when: conda_env_use_spec tags: - pywps - conda diff --git a/vars/main.yml b/vars/main.yml index de473e3..efee9c4 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -4,6 +4,8 @@ miniconda_make_sys_default: False # conda conda_location: "{{ prefix }}/anaconda" conda_envs_dir: "{{ conda_location }}/envs" +conda_env_use_spec: false +conda_env_spec_file: spec-file.txt # supervisor supervisor_user: root supervisor_password: 'test'