Get STDOUT and STDERR for each function

9 views
Skip to first unread message

Amit Bhardwaj

unread,
Apr 10, 2018, 3:55:57 AM4/10/18
to Salt-users
Hello all, 

My use-case is to get STDERR/STDOUT of each module/function/sub-state in a state file towards salt-master's event listener. 

My state file(test.sls) looks like this:

{% for pkg in 'foo', 'g++','make', 'sysstat', 'apache2' %}
{{ pkg }}:
  pkg
.installed:
     
- skip_verify: True
     
- order: 1
 
event:
   
- send  
   
- name: salt/job/critical
   
- unless:
     
- dpkg -l {{ pkg }}
   
- data:  
        status
: 'False'
        failure_at
: {{ pkg }}
{% endfor %}

The above code will install packages from the list and send a failure event to salt MASTER in case a package fails to install. I am relying on dpkg -l to check if the package is available on OS or not. But, I also want to get STDOUT/STDERR for each installation rather than a summarized output which is returned to MASTER after salt '*' state.apply test

This will help me detect the reason why a specific package failed to install. It could be due to varioud reasons like dependencies failure or apt-get repository being unavailable and so on. 

What can be done to get the STDOUT/STDERR for each sub-state execution? 
Reply all
Reply to author
Forward
0 new messages