|
|
@@ -22,23 +22,48 @@ salt_minion_grains_files: |
|
|
|
- require: |
|
|
|
- file: salt_minion_grains_dir |
|
|
|
|
|
|
|
{%- set new_grains = salt['cmd.run']('cat /etc/salt/grains.d/*') %} |
|
|
|
{%- set old_grains = salt['cmd.run']('cat /etc/salt/grains') %} |
|
|
|
salt_minion_grains_pkg_validity_check: |
|
|
|
pkg.installed: |
|
|
|
- pkgs: {{ minion.grains_validity_pkgs }} |
|
|
|
|
|
|
|
{%- if new_grains != old_grains %} |
|
|
|
{%- for service_name, service in pillar.items() %} |
|
|
|
{%- set support_fragment_file = service_name+'/meta/salt.yml' %} |
|
|
|
{%- macro load_support_file() %}{% include support_fragment_file ignore missing %}{% endmacro %} |
|
|
|
{%- set support_yaml = load_support_file()|load_yaml %} |
|
|
|
|
|
|
|
{%- if support_yaml %} |
|
|
|
{%- for name, grain in support_yaml.get('grain', {}).iteritems() %} |
|
|
|
salt_minion_grain_{{ service_name }}_{{ name }}: |
|
|
|
file.managed: |
|
|
|
- name: /etc/salt/grains.d/{{ name }} |
|
|
|
- contents: | |
|
|
|
{{ grain|yaml(False)|indent(8) }} |
|
|
|
- require: |
|
|
|
- file: salt_minion_grains_dir |
|
|
|
|
|
|
|
salt_minion_grain_{{ service_name }}_{{ name }}_validity_check: |
|
|
|
cmd.wait: |
|
|
|
- name: python -c "import yaml; stream = file('/etc/salt/grains.d/{{ name }}', 'r'); yaml.load(stream); stream.close()" |
|
|
|
- require: |
|
|
|
- pkg: salt_minion_grains_pkg_validity_check |
|
|
|
- watch: |
|
|
|
- file: salt_minion_grain_{{ service_name }}_{{ name }} |
|
|
|
- watch_in: |
|
|
|
- cmd: salt_minion_grains_file |
|
|
|
{%- endfor %} |
|
|
|
{%- endif %} |
|
|
|
{%- endfor %} |
|
|
|
|
|
|
|
salt_minion_grains_file: |
|
|
|
cmd.run: |
|
|
|
cmd.wait: |
|
|
|
- name: cat /etc/salt/grains.d/* > /etc/salt/grains |
|
|
|
- require: |
|
|
|
- file: salt_minion_grains_files |
|
|
|
|
|
|
|
salt_minion_grains_publish: |
|
|
|
module.run: |
|
|
|
module.wait: |
|
|
|
- name: mine.update |
|
|
|
- require: |
|
|
|
- watch: |
|
|
|
- cmd: salt_minion_grains_file |
|
|
|
|
|
|
|
{%- endif %} |
|
|
|
|
|
|
|
{%- endif %} |