Make salt.minion.grains idempotent (poor man solution)
diff --git a/salt/minion/grains.sls b/salt/minion/grains.sls
index 972577c..dd8b436 100644
--- a/salt/minion/grains.sls
+++ b/salt/minion/grains.sls
@@ -14,24 +14,34 @@
- {{ minion.install_state }}
salt_minion_grains_placeholder:
- file.touch:
+ file.managed:
- name: /etc/salt/grains.d/placeholder
+ - replace: false
- require:
- file: salt_minion_grains_dir
+{#
+ TODO: we need to be idempotent but reload salt-minion when grains are
+ changed. So for now, adding new grains requires removal of /etc/salt/grains
+ file and execution of salt state again
+ This can be possibly solved by custom module for grains management or native
+ support for grains.d in salt
+#}
salt_minion_grains_file:
cmd.run:
- name: cat /etc/salt/grains.d/* > /etc/salt/grains
+ - creates: /etc/salt/grains
- require:
- file: salt_minion_grains_placeholder
- watch_in:
- service: salt_minion_service
salt_minion_grains_publish:
- module.run:
+ module.wait:
- name: mine.send
- name: grains.items
- - require:
+ - watch:
+ - service: salt_minion_service
- cmd: salt_minion_grains_file
{%- endif %}