From 7ca49ea62cda75ab357b3c7b9cdcbdd0e7a9d7e1 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Tue, 25 Jan 2022 00:16:58 +0100 Subject: [PATCH] updated config state --- states/config/config.json.j2 | 2 ++ states/config/defaults.yaml | 3 ++- states/config/init.sls | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 states/config/config.json.j2 diff --git a/states/config/config.json.j2 b/states/config/config.json.j2 new file mode 100644 index 0000000..b0bf74b --- /dev/null +++ b/states/config/config.json.j2 @@ -0,0 +1,2 @@ +{%- from "config/map.jinja" import config with context -%} +{{ config.config|json }} diff --git a/states/config/defaults.yaml b/states/config/defaults.yaml index 8df4e56..c7f1d1e 100644 --- a/states/config/defaults.yaml +++ b/states/config/defaults.yaml @@ -2,5 +2,6 @@ config: enabled: true install_dir: "/usr/local/apps/config" - filename: "common.ini" + ini_filename: "common.ini" + json_filename: "common.json" config: {} diff --git a/states/config/init.sls b/states/config/init.sls index 24ca5a8..36760ea 100644 --- a/states/config/init.sls +++ b/states/config/init.sls @@ -6,14 +6,22 @@ config-dir: - user: root - mode: "0755" -config-file: +config-ini-create: file.managed: - - name: {{ config.install_dir }}/{{ config.filename }} + - name: {{ config.install_dir }}/{{ config.ini_filename }} - user: root - mode: "0755" -config-file-config: +config-ini-content: ini.options_present: - - name: {{ config.install_dir }}/{{ config.filename }} + - name: {{ config.install_dir }}/{{ config.ini_filename }} - separator: '=' - sections: {{ config.config }} + +config-json-content: + file.managed: + - name: {{ config.install_dir }}/{{ config.json_filename }} + - source: salt://config/config.json.j2 + - user: root + - mode: "0755" + - template: jinja