I would like to share the output of a command from one node to the other on running salt "*" state.apply
.
My current solution involves mine.send
and mine.get
:
$ cat top.sls
base:
'master*':
- states.master*
'worker*':
- states.worker*
$ cat states/master.sls
save:
module.run:
- mine.send:
- foo
- mine_function: cmd.shell
- name: whoami
$ cat states/worker.sls
load:
file.managed:
- name: /tmp/a.sh
- contents: {{ salt['mine.get']("*", "foo").values() | first }}
On first run, I get the following error for the “worker” node:
worker-0:
Data failed to compile:
----------
Rendering SLS 'base:states.worker' failed: Jinja variable No first item, sequence was empty.; line 7
---
[...]
load:
file.managed:
- name: /tmp/a.sh
- contents: {{ salt['mine.get']("*", "foo").values() | first }}
---
On second run it works as expected.
I am assuming that the problem is that the mine.get
does not wait for the mine.send
but it tries to fetch the variable on creating the template.
Any suggestions?
Thanks