FAQ
Hi Donavan,
have you solved your problem?
I am stuck with the same one :-)

Best regards, Markus
On Friday, November 8, 2013 5:55:49 PM UTC+1, Donovan Graham wrote:

Hi

No I don't have another state, as I'm not currently managing the file.
I'll try to see if your suggestion helps.

Thanks
Donovan
--
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

  • Markus Kramer at Jul 18, 2014 at 1:08 pm
    Hi Dave,
    it does work with an extra state (that requires a colon).

    write_Yes:
       cmd:
         - run
         - cwd: /salt
         - name: WriteYes
         - require:
           - file: writeYesTrigger
    writeYesTrigger:
       file.exists:
         - name: /salt/writeYesTrigger.txt

    The extra state introduces one level on indirektion without any value.
    How can it be done without an extra state?

    Markus

    On Friday, November 8, 2013 5:41:13 PM UTC+1, David Anderson wrote:

    Do you have a state that checks file.exists on
    /usr/local/bin/virtualenvwrapper.sh ?

    E.g.:


    /usr/local/bin/virtualenvwrapper.sh:
    file.exists:

    --
    Dave

    On 11/8/13 8:02 AM, Donovan Graham wrote:
    Hi

    I would like to test for the existence of a file which is
    independently installed by another package. If I uncomment the line
    in example below, i get a " The following requisites were not found:"
    error. I have also tried to move the logic into the unless statement,
    but didn't have luck. Please could you advise.

    /root/.bashrc:
    file:
    - append
    - text:
    - export WORKON_HOME=/usr/local/virtualenv
    - source /usr/local/bin/virtualenvwrapper.sh
    - unless:
    - "sudo grep '^export WORKON_HOME' /root/.bashrc"
    - require:
    - pip.installed: virtualenvwrapper
    - file.directory: /usr/local/virtualenv
    # - file.exists: /usr/local/bin/virtualenvwrapper.sh ## this
    line doesn't work


    Many thanks, again:)
    Donovan
    --
    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 <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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.
  • Ryan Lane at Jul 18, 2014 at 4:29 pm

    On Fri, Jul 18, 2014 at 6:08 AM, Markus Kramer wrote:

    Hi Dave,
    it does work with an extra state (that requires a colon).

    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - require:
    - file: writeYesTrigger
    write_Yes:
       cmd:
         - run
         - cwd: /salt
         - name: WriteYes
         - onlyif:
           - cmd: test -f /salt/writeYesTrigger.txt

    If you're trying to run a command based on the existence of a file, the
    above works.

    Sorry if this isn't what you're after, this thread is missing context.

    - Ryan

    --
    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.
  • Markus Kramer at Jul 22, 2014 at 4:20 pm
    Hi Ryan,
    thank you - this is exactly what I was after :-)

    But I found a new problem:
    On Windows test -f /salt/file.txt always return TRUE, also if
    the file does not exist.
    therefore the only-if guarded command (WriteYes) is always executed.

    Should I report this as a bug?

    I tried to leave out "cmd: " in "cmd: test", as below, and it seems to be
    legal Salt:
         - onlyif:
           - test -f /salt/writeYesTrigger.txt
    Under Windows, this has the same result as with the "cmd: ", but does the
    "cmd: " make a difference?

    Best regards,
    Markus


    Am Freitag, 18. Juli 2014 18:29:11 UTC+2 schrieb Ryan Lane:
    On Fri, Jul 18, 2014 at 6:08 AM, Markus Kramer <markus...@dhl.com
    <javascript:>> wrote:
    Hi Dave,
    it does work with an extra state (that requires a colon).

    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - require:
    - file: writeYesTrigger
    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - onlyif:
    - cmd: test -f /salt/writeYesTrigger.txt

    If you're trying to run a command based on the existence of a file, the
    above works.

    Sorry if this isn't what you're after, this thread is missing context.

    - Ryan
    --
    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.
  • Markus Kramer at Jul 22, 2014 at 4:27 pm
    Hi Ryan,
    thank you - this is exactly what I was after :-)

    But I found a new problem:
    On Windows test -f /salt/file.txt always return TRUE, also if
    the file does not exist.
    therefore the only-if guarded command (WriteYes) is always executed.

    Should I report this as a bug?

    Also, I can leave out "cmd: " in "cmd: test", as below, and it seems to be
    legal Salt:
         - onlyif:
           - test -f /salt/writeYesTrigger.txt
    Under Windows, this has the same result as with "cmd: ", but does "cmd: "
    make a difference?

    Best regards,
    Markus

    Am Freitag, 18. Juli 2014 18:29:11 UTC+2 schrieb Ryan Lane:
    On Fri, Jul 18, 2014 at 6:08 AM, Markus Kramer <markus...@dhl.com
    <javascript:>> wrote:
    Hi Dave,
    it does work with an extra state (that requires a colon).

    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - require:
    - file: writeYesTrigger
    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - onlyif:
    - cmd: test -f /salt/writeYesTrigger.txt

    If you're trying to run a command based on the existence of a file, the
    above works.

    Sorry if this isn't what you're after, this thread is missing context.

    - Ryan
    --
    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 Aug 7, 2014 at 9:39 pm
    If you remove the `cmd: ` does it still always return True? I'm not sure
    that `cmd: ` was ever needed there, I think it runs the command by default,
    and for all I know, adding that `cmd: ` there could be the cause of your
    issues.

    --
    Colton Myers

    On Tue, Jul 22, 2014 at 10:27 AM, Markus Kramer wrote:

    Hi Ryan,
    thank you - this is exactly what I was after :-)

    But I found a new problem:
    On Windows test -f /salt/file.txt always return TRUE, also
    if the file does not exist.
    therefore the only-if guarded command (WriteYes) is always executed.

    Should I report this as a bug?

    Also, I can leave out "cmd: " in "cmd: test", as below, and it seems to
    be legal Salt:

    - onlyif:
    - test -f /salt/writeYesTrigger.txt
    Under Windows, this has the same result as with "cmd: ", but does "cmd: "
    make a difference?


    Best regards,
    Markus

    Am Freitag, 18. Juli 2014 18:29:11 UTC+2 schrieb Ryan Lane:
    On Fri, Jul 18, 2014 at 6:08 AM, Markus Kramer wrote:

    Hi Dave,
    it does work with an extra state (that requires a colon).

    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - require:
    - file: writeYesTrigger
    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - onlyif:
    - cmd: test -f /salt/writeYesTrigger.txt

    If you're trying to run a command based on the existence of a file, the
    above works.

    Sorry if this isn't what you're after, this thread is missing context.

    - Ryan
    --
    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.
  • Markus Kramer at Aug 18, 2014 at 12:46 pm
    Hi Colton,
    yes, sadly "test -f" always returns True.

    When I execute the code below, two notepads open, regardless if file
    /plan/salt/writeYesTrigger.txt exists or not.
    This means: I does not matter if "cmd:" stands in front of "test -f". (form
    1) or not (form 2)

    I also tested a third form: "onlyif" and "test" in one row always return
    False!

    Can you please decide if this is this a bug or wrong SLS code?

    Tested with release 2014.1.10 on Windows 7, 64bit.
    Best regards,
    Markus

    always_Yes1:
       cmd:
         - run
         - cwd: /
         - name: notepad
         - onlyif:
           - cmd: test -f /plan/salt/writeYesTrigger.txt


    always_Yes2:
       cmd:
         - run
         - cwd: /
         - name: notepad
         - onlyif:
           - test -f /plan/salt/writeYesTrigger.txt


    never_Yes3:
       cmd:
         - run
         - cwd: /plan/salt/
         - name: notepad YES.txt
         - onlyif: test -f /plan/salt/writeYesTrigger.txt






    On Thursday, August 7, 2014 11:39:09 PM UTC+2, basepi wrote:

    If you remove the `cmd: ` does it still always return True? I'm not sure
    that `cmd: ` was ever needed there, I think it runs the command by default,
    and for all I know, adding that `cmd: ` there could be the cause of your
    issues.

    --
    Colton Myers


    On Tue, Jul 22, 2014 at 10:27 AM, Markus Kramer <markus...@dhl.com
    <javascript:>> wrote:
    Hi Ryan,
    thank you - this is exactly what I was after :-)

    But I found a new problem:
    On Windows test -f /salt/file.txt always return TRUE, also
    if the file does not exist.
    therefore the only-if guarded command (WriteYes) is always executed.

    Should I report this as a bug?

    Also, I can leave out "cmd: " in "cmd: test", as below, and it seems to
    be legal Salt:

    - onlyif:
    - test -f /salt/writeYesTrigger.txt
    Under Windows, this has the same result as with "cmd: ", but does "cmd: "
    make a difference?


    Best regards,
    Markus

    Am Freitag, 18. Juli 2014 18:29:11 UTC+2 schrieb Ryan Lane:
    On Fri, Jul 18, 2014 at 6:08 AM, Markus Kramer <markus...@dhl.com>
    wrote:
    Hi Dave,
    it does work with an extra state (that requires a colon).

    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - require:
    - file: writeYesTrigger
    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - onlyif:
    - cmd: test -f /salt/writeYesTrigger.txt

    If you're trying to run a command based on the existence of a file, the
    above works.

    Sorry if this isn't what you're after, this thread is missing context.

    - Ryan
    --
    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 <javascript:>.
    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.
  • Daniel Jagszent at Aug 18, 2014 at 12:56 pm
    Hi Markus,

    the third option is the right syntax.

    Are you sure there is a "test" executable in windows? Doesn't look like
    it when I e.g. read
    https://superuser.com/questions/219050/how-to-check-if-a-directory-exists-in-windows

    Markus Kramer wrote:
    Hi Colton,
    yes, sadly "test -f" always returns True.

    When I execute the code below, two notepads open, regardless if file
    /plan/salt/writeYesTrigger.txt exists or not.
    This means: I does not matter if "cmd:" stands in front of "test -f".
    (form 1) or not (form 2)

    I also tested a third form: "onlyif" and "test" in one row always
    return False!

    Can you please decide if this is this a bug or wrong SLS code?

    Tested with release 2014.1.10 on Windows 7, 64bit.
    Best regards,
    Markus

    always_Yes1:
    cmd:
    - run
    - cwd: /
    - name: notepad
    - onlyif:
    - cmd: test -f /plan/salt/writeYesTrigger.txt


    always_Yes2:
    cmd:
    - run
    - cwd: /
    - name: notepad
    - onlyif:
    - test -f /plan/salt/writeYesTrigger.txt


    never_Yes3:
    cmd:
    - run
    - cwd: /plan/salt/
    - name: notepad YES.txt
    - onlyif: test -f /plan/salt/writeYesTrigger.txt







    On Thursday, August 7, 2014 11:39:09 PM UTC+2, basepi wrote:

    If you remove the `cmd: ` does it still always return True? I'm
    not sure that `cmd: ` was ever needed there, I think it runs the
    command by default, and for all I know, adding that `cmd: ` there
    could be the cause of your issues.

    --
    Colton Myers


    On Tue, Jul 22, 2014 at 10:27 AM, Markus Kramer <markus...@dhl.com
    <javascript:>> wrote:

    Hi Ryan,
    thank you - this is exactly what I was after :-)

    But I found a new problem:
    On Windows test -f /salt/file.txt always return
    TRUE, also if the file does not exist.
    therefore the only-if guarded command (WriteYes) is always
    executed.

    Should I report this as a bug?

    Also, I can leave out "cmd: " in "cmd: test", as below, and it
    seems to be legal Salt:

    - onlyif:
    - test -f /salt/writeYesTrigger.txt
    Under Windows, this has the same result as with "cmd: ", but
    does "cmd: " make a difference?


    Best regards,
    Markus

    Am Freitag, 18. Juli 2014 18:29:11 UTC+2 schrieb Ryan Lane:

    On Fri, Jul 18, 2014 at 6:08 AM, Markus Kramer
    wrote:

    Hi Dave,
    it does work with an extra state (that requires a colon).

    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - require:
    - file: writeYesTrigger


    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - onlyif:
    - cmd: test -f /salt/writeYesTrigger.txt

    If you're trying to run a command based on the existence
    of a file, the above works.

    Sorry if this isn't what you're after, this thread is
    missing context.

    - Ryan

    --
    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
    <javascript:>.
    For more options, visit https://groups.google.com/d/optout
    <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.
  • Markus Kramer at Aug 18, 2014 at 1:45 pm
    Hi Daniel,
    well, if form 1 and 2 are "wrong syntax" why doesn't Salt tells or warns me
    at compile time?
    Are there options to generate compiler warnings?
    Also: what is wrong?

    Interesting: there is an ERROR in the log, which tells me that " 'test' is
    not a recognized command."
    Salt needs to halt execution on this kind of ERROR!

    This is the old discussion of how to calculate with 1/0 (or 'undefinded').
    If 'test' does not exist, then the result of test is undefined. The program
    must not "assume" that it's False.
    Calculation with undefined (or null) must halt the program or throw an
    exeption.
    Writing a log entry is, I regret to say it, not acceptable.

    On Monday, August 18, 2014 2:56:13 PM UTC+2, Daniel Jagszent wrote:

    Hi Markus,

    the third option is the right syntax.

    Are you sure there is a "test" executable in windows? Doesn't look like it
    when I e.g. read
    https://superuser.com/questions/219050/how-to-check-if-a-directory-exists-in-windows

    Markus Kramer wrote:

    Hi Colton,
    yes, sadly "test -f" always returns True.

    When I execute the code below, two notepads open, regardless if file
    /plan/salt/writeYesTrigger.txt exists or not.
    This means: I does not matter if "cmd:" stands in front of "test -f".
    (form 1) or not (form 2)

    I also tested a third form: "onlyif" and "test" in one row always return
    False!

    Can you please decide if this is this a bug or wrong SLS code?

    Tested with release 2014.1.10 on Windows 7, 64bit.
    Best regards,
    Markus

    always_Yes1:
    cmd:
    - run
    - cwd: /
    - name: notepad
    - onlyif:
    - cmd: test -f /plan/salt/writeYesTrigger.txt


    always_Yes2:
    cmd:
    - run
    - cwd: /
    - name: notepad
    - onlyif:
    - test -f /plan/salt/writeYesTrigger.txt


    never_Yes3:
    cmd:
    - run
    - cwd: /plan/salt/
    - name: notepad YES.txt
    - onlyif: test -f /plan/salt/writeYesTrigger.txt






    On Thursday, August 7, 2014 11:39:09 PM UTC+2, basepi wrote:

    If you remove the `cmd: ` does it still always return True? I'm not sure
    that `cmd: ` was ever needed there, I think it runs the command by default,
    and for all I know, adding that `cmd: ` there could be the cause of your
    issues.

    --
    Colton Myers


    On Tue, Jul 22, 2014 at 10:27 AM, Markus Kramer <markus...@dhl.com>
    wrote:
    Hi Ryan,
    thank you - this is exactly what I was after :-)

    But I found a new problem:
    On Windows test -f /salt/file.txt always return TRUE, also
    if the file does not exist.
    therefore the only-if guarded command (WriteYes) is always executed.

    Should I report this as a bug?

    Also, I can leave out "cmd: " in "cmd: test", as below, and it seems to
    be legal Salt:

    - onlyif:
    - test -f /salt/writeYesTrigger.txt
    Under Windows, this has the same result as with "cmd: ", but does "cmd: "
    make a difference?


    Best regards,
    Markus

    Am Freitag, 18. Juli 2014 18:29:11 UTC+2 schrieb Ryan Lane:
    On Fri, Jul 18, 2014 at 6:08 AM, Markus Kramer <markus...@dhl.com>
    wrote:
    Hi Dave,
    it does work with an extra state (that requires a colon).

    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - require:
    - file: writeYesTrigger
    write_Yes:
    cmd:
    - run
    - cwd: /salt
    - name: WriteYes
    - onlyif:
    - cmd: test -f /salt/writeYesTrigger.txt

    If you're trying to run a command based on the existence of a file, the
    above works.

    Sorry if this isn't what you're after, this thread is missing context.

    - Ryan
    --
    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.
    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+...@googlegroups.com <javascript:>.
    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.
  • Seth House at Aug 18, 2014 at 3:31 pm

    On Mon, Aug 18, 2014 at 7:45 AM, Markus Kramer wrote:
    Interesting: there is an ERROR in the log, which tells me that " 'test' is
    not a recognized command."
    Salt needs to halt execution on this kind of ERROR!
    That is indeed the normal behavior. This sounds like a Windows-related
    bug. Will you please file an issue on GitHub? We'll get that fixed.

    --
    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 @
postedJul 18, '14 at 12:12p
activeAug 18, '14 at 3:31p
posts10
users5

People

Translate

site design / logo © 2022 Grokbase