Get STDOUT and STDERR for each function

9 visualizações
Pular para a primeira mensagem não lida

Amit Bhardwaj

não lida,
10 de abr. de 2018, 03:55:5710/04/2018
para 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? 
Responder a todos
Responder ao autor
Encaminhar
0 nova mensagem