From f7fe658aeeedcec38f6fa34b063d563fb2fd51dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ga=C3=ABtan=20Duchaussois?= Date: Mon, 26 Feb 2018 10:54:37 +0100 Subject: [PATCH] define safe default variable for clever and rename clever_app_tasks to clever_app_tasks_file --- .gitignore | 2 ++ README.md | 4 +++- defaults/main.yml | 3 ++- tasks/main.yml | 4 ++-- templates/env.j2 | 2 +- vars/main.yml | 7 ++++++- 6 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..323f145 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +ansible.cfg +*.retry diff --git a/README.md b/README.md index b049e6e..365a657 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,12 @@ Variables for the application - `clever_token`: clever_cloud token, mandatory. - `clever_secret`: clever_cloud secret, mandatory. - `clever_app`: the id of the app to link, mandatory. +- `clever_entry_point`: the executable name to be executed by clever cloud, mandatory - `clever_env`: a dict of environment variables for the application (without add_ons one already available), optional. +- `clever_base_env`: a dict set in vars/main.yml with safe default and mandatory variables for an app to be run on clever. ` clever_base_env | combine(clever_env)` is passed to `clever env` command - `clever_addons`: a list of dict describing addons enabled for the application from which we would use information during deploy, optional.
Example: `{ name: pg, env_prefix: POSTGRESQL_ADDON }` -- `clever_app_tasks`: tasks file to be executed after environment and addons variables where gathered. Specific to an app, should be use to run migrations. Optional. +- `clever_app_tasks_file`: tasks file to be executed after environment and addons variables where gathered. Specific to an app, should be use to run migrations. Optional. - `domain`: the domain from which the application should be reachable, optional - `syslog_server`: UDP Syslog server to be used as UDPSyslog drain for the application, optional. Example: `udp://198.51.100.51:12345`. diff --git a/defaults/main.yml b/defaults/main.yml index eaf3173..5271a84 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,7 +6,8 @@ clever_app_root: "{{ playbook_dir }}/.." clever_app_confdir: "{{ clever_app_root }}/.clever_cloud" clever_login_file: "{{ clever_app_confdir }}/login" -clever_env: {} +clever_entry_point: "" +clever_extra_env: {} clever_addons: [] # example diff --git a/tasks/main.yml b/tasks/main.yml index fa23f6c..2c9a61e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -19,8 +19,8 @@ - clever-env - name: Include specific tasks - include_tasks: "{{ clever_app_tasks }}" - when: clever_app_tasks is defined + include_tasks: "{{ clever_app_tasks_file }}" + when: clever_app_tasks_file is defined tags: - clever - clever-specific-role diff --git a/templates/env.j2 b/templates/env.j2 index 6010f07..d543a81 100644 --- a/templates/env.j2 +++ b/templates/env.j2 @@ -1,3 +1,3 @@ -{% for key, value in clever_env.iteritems() %} +{% for key, value in (clever_base_env | combine(clever_env)).iteritems() %} {{ key }}={{ value }} {% endfor %} diff --git a/vars/main.yml b/vars/main.yml index 19478fd..0b7f10a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,7 @@ --- -# vars file for clever \ No newline at end of file +# vars file for clever +clever_base_env: + CACHE_DEPENDENCIES: "true" + CC_RUN_COMMAND: "~/.local/bin/{{ clever_entry_point }}" + ENABLE_METRICS: "false" + PORT: "8080" -- 2.41.0