Browse Source

Make salt.minion.grains idempotent (poor man solution)

idempotency
Filip Pytloun 8 years ago
parent
commit
cf85b322cc
1 changed files with 13 additions and 3 deletions
  1. +13
    -3
      salt/minion/grains.sls

+ 13
- 3
salt/minion/grains.sls View File

@@ -14,24 +14,34 @@ salt_minion_grains_dir:
- {{ 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 %}

Loading…
Cancel
Save