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