FAQ
Had a quick question - I was curious as to how you can actually get
orchestrate to stop, mid run? I don't want the run to continue if a
previous step failed.


Here's a contrived example:


cmd.run:
   salt.function:
     - tgt: 'alpha'
     - arg:
       - 'ls -l /tmp'
     - require:
       - salt: test

test:
   salt.function:
     - name: test.false
     - tgt: 'alpha'


But that doesn't do anything. It executes the test.false, which returns
false, but salt sees that as success, so it executes the 'ls -l /tmp'. The
only way I've been able to get it to break was either call an invalid
minion name or to try with test.retcode and provide a non-zero exit code.
  Should I be doing that in any execution modules I write ( return non-zero
codes.. ) for when I have a failure?



--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Steve Hajducko at Oct 8, 2015 at 5:54 am
    So, to answer my own question:

    Yes, there is. I was using 'require' wrong, which just means that
    something must execute before it does. So yes, while test.false returns
    false, it does, indeed, execute.

    However, switching the requisite to 'onlyif' got me what I expected:

    alpha_master:
    ----------
               ID: cmd.run
         Function: salt.function
           Result: True
          Comment: onlyif execution failed
          Started: 22:53:50.848611
         Duration: 654.3 ms
          Changes:
    ----------
               ID: test
         Function: salt.function
             Name: test.false
           Result: True
          Comment: Function ran successfully. Function test.false ran on alpha.
          Started: 22:53:51.503121
         Duration: 5039.537 ms
          Changes:
                   alpha:
                       False


    Summary for alpha_master
    ------------
    Succeeded: 2 (changed=1)
    Failed: 0
    ------------
    Total states run: 2
    Total run time: 5.694 s





    On Tuesday, October 6, 2015 at 2:09:30 PM UTC-7, Steve Hajducko wrote:

    Had a quick question - I was curious as to how you can actually get
    orchestrate to stop, mid run? I don't want the run to continue if a
    previous step failed.


    Here's a contrived example:


    cmd.run:
    salt.function:
    - tgt: 'alpha'
    - arg:
    - 'ls -l /tmp'
    - require:
    - salt: test

    test:
    salt.function:
    - name: test.false
    - tgt: 'alpha'


    But that doesn't do anything. It executes the test.false, which returns
    false, but salt sees that as success, so it executes the 'ls -l /tmp'. The
    only way I've been able to get it to break was either call an invalid
    minion name or to try with test.retcode and provide a non-zero exit code.
    Should I be doing that in any execution modules I write ( return non-zero
    codes.. ) for when I have a failure?


    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Steve Hajducko at Oct 8, 2015 at 6:02 am
    And nevermind that last message, because I totally misunderstood what
    onlyif was doing! Mea culpa.

    Back to the drawing board.
    On Wednesday, October 7, 2015 at 10:54:21 PM UTC-7, Steve Hajducko wrote:

    So, to answer my own question:

    Yes, there is. I was using 'require' wrong, which just means that
    something must execute before it does. So yes, while test.false returns
    false, it does, indeed, execute.

    However, switching the requisite to 'onlyif' got me what I expected:

    alpha_master:
    ----------
    ID: cmd.run
    Function: salt.function
    Result: True
    Comment: onlyif execution failed
    Started: 22:53:50.848611
    Duration: 654.3 ms
    Changes:
    ----------
    ID: test
    Function: salt.function
    Name: test.false
    Result: True
    Comment: Function ran successfully. Function test.false ran on alpha.
    Started: 22:53:51.503121
    Duration: 5039.537 ms
    Changes:
    alpha:
    False


    Summary for alpha_master
    ------------
    Succeeded: 2 (changed=1)
    Failed: 0
    ------------
    Total states run: 2
    Total run time: 5.694 s





    On Tuesday, October 6, 2015 at 2:09:30 PM UTC-7, Steve Hajducko wrote:

    Had a quick question - I was curious as to how you can actually get
    orchestrate to stop, mid run? I don't want the run to continue if a
    previous step failed.


    Here's a contrived example:


    cmd.run:
    salt.function:
    - tgt: 'alpha'
    - arg:
    - 'ls -l /tmp'
    - require:
    - salt: test

    test:
    salt.function:
    - name: test.false
    - tgt: 'alpha'


    But that doesn't do anything. It executes the test.false, which returns
    false, but salt sees that as success, so it executes the 'ls -l /tmp'. The
    only way I've been able to get it to break was either call an invalid
    minion name or to try with test.retcode and provide a non-zero exit code.
    Should I be doing that in any execution modules I write ( return non-zero
    codes.. ) for when I have a failure?


    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colton Myers at Oct 16, 2015 at 12:04 am
    This is an interesting use case. The biggest problem is that modules don't have a defined "Failure" condition like state runs do. Requisites are really only designed to work with states, because states have very defined "Failure" conditions. (Specifically, `result: False` is a failure)

    Just because an execution module returns False doesn't necessarily mean the run was a failure...

    I'll have to think more about this, but I think for now you should open an issue for the ability to use requisites with salt.function in orchestrate runs so we can discuss more. Ping me (@basepi) in the issue, please!

    --
    Colton Myers
    Core Engineer, SaltStack
    @basepi on Twitter/Github/IRC
    On Oct 8, 2015, at 12:02 AM, Steve Hajducko wrote:

    And nevermind that last message, because I totally misunderstood what onlyif was doing! Mea culpa.

    Back to the drawing board.

    On Wednesday, October 7, 2015 at 10:54:21 PM UTC-7, Steve Hajducko wrote:
    So, to answer my own question:

    Yes, there is. I was using 'require' wrong, which just means that something must execute before it does. So yes, while test.false returns false, it does, indeed, execute.

    However, switching the requisite to 'onlyif' got me what I expected:

    alpha_master:
    ----------
    ID: cmd.run
    Function: salt.function
    Result: True
    Comment: onlyif execution failed
    Started: 22:53:50.848611
    Duration: 654.3 ms
    Changes:
    ----------
    ID: test
    Function: salt.function
    Name: test.false
    Result: True
    Comment: Function ran successfully. Function test.false ran on alpha.
    Started: 22:53:51.503121
    Duration: 5039.537 ms
    Changes:
    alpha:
    False


    Summary for alpha_master
    ------------
    Succeeded: 2 (changed=1)
    Failed: 0
    ------------
    Total states run: 2
    Total run time: 5.694 s






    On Tuesday, October 6, 2015 at 2:09:30 PM UTC-7, Steve Hajducko wrote:
    Had a quick question - I was curious as to how you can actually get orchestrate to stop, mid run? I don't want the run to continue if a previous step failed.



    Here's a contrived example:




    cmd.run:
    salt.function:
    - tgt: 'alpha'
    - arg:
    - 'ls -l /tmp'
    - require:
    - salt: test

    test:
    salt.function:
    - name: test.false
    - tgt: 'alpha'



    But that doesn't do anything. It executes the test.false, which returns false, but salt sees that as success, so it executes the 'ls -l /tmp'. The only way I've been able to get it to break was either call an invalid minion name or to try with test.retcode and provide a non-zero exit code. Should I be doing that in any execution modules I write ( return non-zero codes.. ) for when I have a failure?






    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedOct 6, '15 at 9:09p
activeOct 16, '15 at 12:04a
posts4
users2

2 users in discussion

Steve Hajducko: 3 posts Colton Myers: 1 post

People

Translate

site design / logo © 2022 Grokbase