From 244339e70a1be830ac02306e1feb4383fe73572b Mon Sep 17 00:00:00 2001 From: Clement Delafargue Date: Thu, 18 Jun 2020 16:09:46 +0200 Subject: Use JSON import for environment variables The env can be provided as a JSON list `[{"name": "PORT", "value": "8080"}]`. The `dict2items` filter provided by ansible is _almost_ what we want, but it keeps the value original types (a boolean is kept as a boolean in the JSON value). Since environment variables are strings and `clever-tools` does not want to make the implicit coercion for us, we need to do it ourselves. --- filter_plugins/env_json_map.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 filter_plugins/env_json_map.py (limited to 'filter_plugins') diff --git a/filter_plugins/env_json_map.py b/filter_plugins/env_json_map.py new file mode 100644 index 0000000..790dea0 --- /dev/null +++ b/filter_plugins/env_json_map.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +class FilterModule(object): + def filters(self): + return {'json_env_map': self.json_env_map} + + def json_env_map(self, env): + return [{'name': k, 'value': str(v)} for k,v in env.items()] -- cgit v1.2.3