Problem:
When launching the job “Salt Run state.highstate - Salt default” which use the Salt Remote Execution provider, no report is generated and send to Foreman.
When launching a state.highstate using the SSH Remote Execution Provider through salt-call, a report is generated, or manually on the machine or minion, a report is generated.
Expected outcome:
A report should be generated and uploaded to Foreman
Foreman and Proxy versions:
Foreman 1.24.2
foreman-salt 13.2.0
python 2.7.5
Distribution and version:
CentOS Linux release 7.7.1908 (Core)
Other relevant data:
I ran 2 highstates: one through the salt remote provider and another using salt-call.
Respectively, ther esults returned through the jobs.list_jobs call return the following output:
The first thing I notice is that the Function are different between a direct highstate and one run throught the remote provider
Since script /usr/sbin/upload-salt-reports is filtering the results based on the Function field, all highstate executed that way are not picked
I have attached the patched files. I’ve patched both version of the process, through the upload-salt-reports and through the reactor.
The patch should cover a normal direct state.highstate and one launched from the module.run
For the reactor, I also patched an issue I noticed doing my test. Converting the data into JSON would sometime break the SLS template dues to the data being injected. I assume some characters in the report are not compatible. So I base64 the data to make sure it’s a plain string being injected in the state. The error I was getting was:
2020-02-13 18:55:27,909 [salt.utils.reactor:106 ][ERROR ][25713] Failed to render "/etc/salt/master.d/foreman_report_upload.sls":
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/utils/reactor.py", line 97, in render_reaction
data=data)
File "/usr/lib/python2.7/site-packages/salt/state.py", line 385, in render_template
**kwargs)
File "/usr/lib/python2.7/site-packages/salt/template.py", line 101, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/usr/lib/python2.7/site-packages/salt/renderers/yaml.py", line 71, in render
raise SaltRenderError(exc)
SaltRenderError: while parsing a block mapping
in "<unicode string>", line 5, column 9
did not find expected key
in "<unicode string>", line 5, column 14039