From: Clement Delafargue Date: Fri, 19 Jun 2020 09:10:12 +0000 (+0200) Subject: Extract environment building tasks from the JSON template X-Git-Tag: v2.6~6^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=d5b5cb172cd488883e2eac0395dbe4d34ddd7a44;p=github%2Ffretlink%2Fansible-clever.git Extract environment building tasks from the JSON template --- diff --git a/defaults/main.yml b/defaults/main.yml index dcf9650..bd3b6a6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,6 +7,7 @@ clever_app_confdir: "{{ clever_app_root }}/.clever_cloud" clever_login_file: "{{ clever_app_confdir }}/login" clever_haskell_entry_point: "{{ clever_entry_point | default(None) }}" +clever_haskell_env: {} clever_env: {} clever_disable_metrics: false diff --git a/tasks/environment.yml b/tasks/environment.yml index 1508ad4..60b31d2 100644 --- a/tasks/environment.yml +++ b/tasks/environment.yml @@ -1,3 +1,13 @@ +- name: Setup haskell-specific environment variables + set_fact: + clever_haskell_env: + CC_RUN_COMMAND: "~/.local/bin/{{ clever_haskell_entry_point }}" + when: clever_haskell_entry_point is defined + +- name: Assemble full environment + set_fact: + clever_env: "{{ clever_base_env | combine(clever_haskell_env) | combine(clever_env) }}" + - name: Create environment file template: src: env.j2 diff --git a/templates/env.j2 b/templates/env.j2 index e97ef43..59f3050 100644 --- a/templates/env.j2 +++ b/templates/env.j2 @@ -1,10 +1,3 @@ -{% set static_env = clever_base_env | combine(clever_env) %} -{% set dynamic_env = {} %} -{% if clever_haskell_entry_point %} -{# Haskell only #} -{# https://www.clever-cloud.com/doc/get-help/reference-environment-variables/#haskell #} -{% set dynamic_env = { 'CC_RUN_COMMAND': '~/.local/bin/' + clever_haskell_entry_point } %} -{% endif %} {# dict2items is not enough here, all the values have to be stringified #} {# git-blame this line for more explanations #} -{{ static_env | combine(dynamic_env) | json_env_map | to_json }} +{{ clever_env | json_env_map | to_json }}