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

- {{ minion.install_state }} - {{ minion.install_state }}


salt_minion_grains_placeholder: salt_minion_grains_placeholder:
file.touch:
file.managed:
- name: /etc/salt/grains.d/placeholder - name: /etc/salt/grains.d/placeholder
- replace: false
- require: - require:
- file: salt_minion_grains_dir - 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: salt_minion_grains_file:
cmd.run: cmd.run:
- name: cat /etc/salt/grains.d/* > /etc/salt/grains - name: cat /etc/salt/grains.d/* > /etc/salt/grains
- creates: /etc/salt/grains
- require: - require:
- file: salt_minion_grains_placeholder - file: salt_minion_grains_placeholder
- watch_in: - watch_in:
- service: salt_minion_service - service: salt_minion_service


salt_minion_grains_publish: salt_minion_grains_publish:
module.run:
module.wait:
- name: mine.send - name: mine.send
- name: grains.items - name: grains.items
- require:
- watch:
- service: salt_minion_service
- cmd: salt_minion_grains_file - cmd: salt_minion_grains_file


{%- endif %} {%- endif %}

Loading…
Cancel
Save