FAQ
Hello,

I wanted to know if there is a good `runner` for checking to see if a
directory/file exists on a master?

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

  • Leonīds Maslovs at Jul 22, 2014 at 7:53 am
    Hi,

    I am not sure what problem you are trying to troubleshoot.

    This is what i do personally.

    1) listing files
    salt minion-id cp.list_master

    2) viewing highstate top.sls
    salt minion-id state.show_top

    3) viewing particular sls file data
    salt minion-id state.show_sls mystate.mysls

    4) debugging sate sls rendering
    salt minion-id cp.get_template salt://path/to/state.sls /minion/dest

    Hope it helps
    On Tuesday, July 22, 2014 8:23:20 AM UTC+3, Damian Myerscough wrote:

    Hello,

    I wanted to know if there is a good `runner` for checking to see if a
    directory/file exists on a master?
    --
    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.
  • Damian Myerscough at Jul 22, 2014 at 4:55 pm
    Hello Leonids,

    I want to be able to break up the hostname within the top.sls. For example,
    say I have a system called web1.example.com and web2.example.com
    I want to run a specific rule for web2 only because it has a one off
    config. In the top.sls file I want something similar to:-

    top.sls
    =====

    {% set host = salt['grains.get']('fqdn').split('.')[0] %}

    base:
       '*':
         - common.configs
         - more.common

    {% if /srv/salt/base/hosts/{{ host }} %}
       '{{ host }}':
         - specific.configs
    {% else %}
       'web*':
         - generic.settings
    {% endif %}


    This is just a pseudo flow of what I want to achieve, I hope this makes
    sense. My overall goal is to allow me to configure one off hosts without
    having to update the top.sls.



    On Tuesday, 22 July 2014 00:53:31 UTC-7, Leonīds Maslovs wrote:

    Hi,

    I am not sure what problem you are trying to troubleshoot.

    This is what i do personally.

    1) listing files
    salt minion-id cp.list_master

    2) viewing highstate top.sls
    salt minion-id state.show_top

    3) viewing particular sls file data
    salt minion-id state.show_sls mystate.mysls

    4) debugging sate sls rendering
    salt minion-id cp.get_template salt://path/to/state.sls /minion/dest

    Hope it helps
    On Tuesday, July 22, 2014 8:23:20 AM UTC+3, Damian Myerscough wrote:

    Hello,

    I wanted to know if there is a good `runner` for checking to see if a
    directory/file exists on a master?
    --
    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.
  • Leonids M at Jul 23, 2014 at 12:21 am
    Hi Damian,

    I see.

    If the path is local to minionyou could use
    {%if salt['file.directory_exists'](path)%}
    see
    http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.file.html#salt.modules.file.directory_exists
    for more info

    If the path is served from Salt FileServer then you probably will need
    to resort to something like {% if 'hosts/'+ host in
    salt['cp.list_master_dir']() %}

    Hope it helps
    On 2014.07.22. 19:55, Damian Myerscough wrote:
    Hello Leonids,

    I want to be able to break up the hostname within the top.sls. For
    example, say I have a system called web1.example.com and web2.example.com
    I want to run a specific rule for web2 only because it has a one off
    config. In the top.sls file I want something similar to:-

    top.sls
    =====

    {% set host = salt['grains.get']('fqdn').split('.')[0] %}

    base:
    '*':
    - common.configs
    - more.common

    {% if /srv/salt/base/hosts/{{ host }} %}
    '{{ host }}':
    - specific.configs
    {% else %}
    'web*':
    - generic.settings
    {% endif %}


    This is just a pseudo flow of what I want to achieve, I hope this makes
    sense. My overall goal is to allow me to configure one off hosts without
    having to update the top.sls.




    On Tuesday, 22 July 2014 00:53:31 UTC-7, Leonīds Maslovs wrote:

    Hi,

    I am not sure what problem you are trying to troubleshoot.

    This is what i do personally.

    1) listing files
    salt minion-id cp.list_master

    2) viewing highstate top.sls
    salt minion-id state.show_top

    3) viewing particular sls file data
    salt minion-id state.show_sls mystate.mysls

    4) debugging sate sls rendering
    salt minion-id cp.get_template salt://path/to/state.sls /minion/dest

    Hope it helps

    On Tuesday, July 22, 2014 8:23:20 AM UTC+3, Damian Myerscough wrote:

    Hello,

    I wanted to know if there is a good `runner` for checking to see
    if a directory/file exists on a master?

    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Salt-users" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/salt-users/BY3BMRwuYJw/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    salt-users+unsubscribe@googlegroups.com
    For more options, visit https://groups.google.com/d/optout.
    --
    wbr
    Leonids M
  • Leonīds Maslovs at Jul 23, 2014 at 1:39 am
    I'm still afraid I might misread you.

    The previous answer was intended to use-case when you want to have HUNDREDS
    of web minions, for SOME of them specific states and being able to redefine
    them dynamically by means of copying host/ files.

    If all you need to accomplish is FQDN targeting, then please take a look
    into
    http://docs.saltstack.com/en/latest/topics/targeting/grains.html#matching-grains-in-the-top-file

    Please also take a look into
    http://docs.saltstack.com/en/latest/topics/targeting/compound.html. You
    might be able to setup something like this:
    for minions with role webserver do this, for all other do that.
    e.g.

    base:
       'G@roles:webserv':
         - match: compound
         - generic.config

       'not G@roles:webserv':
         - match: compound
         - specific.config


    I mean it all depends on your scale and your needs. Is it ok to change
    top.sls file on change or do you want to copy over host folders (like
    serv1, serv2, serv3) and make top.sls automatically detect them and do the
    right thing?

    As a rule of thumb I try to avoid logic / code in my sls files, especially
    in highstate top.sls. So, if you indeed could avoid that by leveraging some
    sort of minion targeting - good for you, goal achieved and you still your
    plain simple readable logic-less sls tempate.


    Hope it helps.

    --
    wbr
    Leonids M

    --
    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.
  • Ethan Erchinger at Jul 23, 2014 at 5:28 pm
    Take a look at this gist. Let me know if you have questions.

    https://gist.github.com/erchn/7629017

    --
    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.
  • Leonids M at Jul 23, 2014 at 5:32 pm
    Hi Ethan,

    Big time thanks for sharing this. I've learned something new today.

    On 2014.07.23. 20:28, Ethan Erchinger wrote:
    Take a look at this gist. Let me know if you have questions.

    https://gist.github.com/erchn/7629017
    --
    wbr
    Leonids M
  • Ethan Erchinger at Jul 23, 2014 at 6:01 pm
    You bet, that's production worthy code, nearly that exact ninja is used every day, in my environment, without issue.

    --
    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.
  • Damian Myerscough at Aug 15, 2014 at 10:10 pm
    Thanks guys, this really helped!
    On Wednesday, 23 July 2014 11:00:59 UTC-7, Ethan Erchinger wrote:

    You bet, that's production worthy code, nearly that exact ninja is used
    every day, in my environment, without issue.
    --
    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 22, '14 at 5:23a
activeAug 15, '14 at 10:10p
posts9
users3

People

Translate

site design / logo © 2022 Grokbase