From 37a932991174276f5d69ec08862feb963a8999fc Mon Sep 17 00:00:00 2001 From: Daniel Dehennin Date: Wed, 9 Feb 2022 08:30:37 +0100 Subject: [PATCH] refactor(salt-master): provide backward compatible states This permit to not break user states which depends on this one. --- salt/master/init.sls | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/salt/master/init.sls b/salt/master/init.sls index 858a8e6..f7bbf09 100644 --- a/salt/master/init.sls +++ b/salt/master/init.sls @@ -1,7 +1,54 @@ # -*- coding: utf-8 -*- # vim: ft=sls +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- from tplroot ~ "/map.jinja" import salt_settings with context %} + include: - .package - .config - .service + +{#- Be backward compatible #} +{%- if grains.kernel != 'Windows' %} +{%- if grains.os == "MacOS" %} +salt-master-macos: + test.show_notification: + - name: salt-master-macos + - text: Backward compatible state for {{ + "'sls:" ~ tplroot ~ ".master.config.files => " + ~ "salt-master-config-files-macos-LaunchDaemons-file.managed'" + }} +{%- endif %} + +{%- set old_states_names = [ + "'sls:" ~ tplroot ~ ".master.package.install => " + ~ "salt-master-package-install-pkg.installed'", + "'sls:" ~ tplroot ~ ".master.config.files => " + ~ "salt-master-config-files-file.recurse'", + "'sls:" ~ tplroot ~ ".master.service", + ] %} +salt-master: + test.show_notification: + - name: salt-master + - text: Backward compatible state for {{ old_states_names | join(", ") }} + +{%- if salt_settings.master_remove_config %} +remove-default-master-conf-file: + test.show_notification: + - name: remove-default-master-conf-file + - text: Backward compatible state for {{ + "'sls:" ~ tplroot ~ ".master.config.files => " + ~ "salt-master-config-files-remove-old-master-conf-file.absent'" + }} +{%- endif %} + +remove-old-master-conf-file: + test.show_notification: + - name: remove-old-master-conf-file + - text: Backward compatible state for {{ + "'sls:" ~ tplroot ~ ".master.config.files => " + ~ "salt-master-config-files-remove-old-default-master-conf-file.absent'" + }} +{%- endif %}