Custom Warning in State

92 views
Skip to first unread message

Vaarlion

unread,
Jul 22, 2019, 10:30:17 AM7/22/19
to Salt-users
Hello :)
Have someone manage to return a custom "warning" message from a state ?
I'm not talking about salt.log.warning but real highstate warning as defined here : https://github.com/saltstack/salt/blob/develop/salt/output/highstate.py#L402...
Sadly, digging in the doc or in google, the info have been drown in "how do i solve this warning" post :(
A custom python thingy is also OK if there is no build-in.

Thank you for reading :)

Phipps, Thomas

unread,
Jul 22, 2019, 1:40:32 PM7/22/19
to salt-...@googlegroups.com
You are going to need a custom python state module for that. It is going to have to have the warning in its return value. 

For most other options one of the test state module functions can handle it but I don't think the test state functions use warnings. 

an example of a state that uses this 


 

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/aa7cac74-2c03-4f64-9e5e-1fdaf57b3561%40googlegroups.com.

Vaarlion

unread,
Jul 23, 2019, 1:31:42 AM7/23/19
to Salt-users
Custom Python are surely OK, i just need to figure out the way to implement them since it's a first, but i do remember reading about it in the doc.
Thank's for the help ! i'll keep digging :)

On Monday, July 22, 2019 at 7:40:32 PM UTC+2, Thomas Phipps wrote:
You are going to need a custom python state module for that. It is going to have to have the warning in its return value. 

For most other options one of the test state module functions can handle it but I don't think the test state functions use warnings. 

an example of a state that uses this 


 

On Mon, Jul 22, 2019 at 7:30 AM Vaarlion <guillaum...@webedia-group.com> wrote:
Hello :)
Have someone manage to return a custom "warning" message from a state ?
I'm not talking about salt.log.warning but real highstate warning as defined here : https://github.com/saltstack/salt/blob/develop/salt/output/highstate.py#L402...
Sadly, digging in the doc or in google, the info have been drown in "how do i solve this warning" post :(
A custom python thingy is also OK if there is no build-in.

Thank you for reading :)

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-...@googlegroups.com.

Max Arnold

unread,
Jul 23, 2019, 5:37:46 AM7/23/19
to Salt-users

Vaarlion

unread,
Jul 23, 2019, 6:12:32 AM7/23/19
to Salt-users
Wow, thanks a lot for that ! i didn't expect that, especial that fast.
I'll still keep looking into custom python because it will be useful in the long run and swap to this when/if it reach main release !

Max Arnold

unread,
Jul 23, 2019, 7:08:50 AM7/23/19
to Salt-users
You can try it right now:

2. Put it into the salt/_states/ dir
3. Run salt '*' saltutil.sync_states

And then try the following state:

A warning:
  test.configurable_test_state:
    - result: True
    - warnings:
        - Hello
        - there

Vaarlion

unread,
Jul 23, 2019, 8:58:32 AM7/23/19
to Salt-users
Thank's ! I had to merge your file with our and do a bit a tweaking since we are on a very old version of salt (nitrogen)
It work except for one thing, and i don't know if it's normal or not.
if i use
A warning:
   test.configurable_test_state:
     - result: True
     - changes: False < This is the cause of it

     - warnings:
       - Hello
       - there


my output don't contain any warnings.
Maybe it is wanted, because a warnings when nothing had change is an odd case...
Reply all
Reply to author
Forward
0 new messages