FAQ
I've got a state that needs to do a DB schema import using cmd.run and I
would like to have salt pull the schema file from the master and use it as
the redirected-in argument on the command. However, I would like to do this
so the file is treated as a temporary one and removed after the import. I
know I could do file.managed to /tmp, cmd.run using that file then
file.absent to remove it but I wonder is there a way to use a file from the
master directly (maybe via the minion cache)?

Regards,
John

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

  • Daniel Jagszent at Jul 9, 2014 at 12:39 pm
    Hi John,

    you could try something like this:

    seed-my-db:
       cmd.run:
       - name: 'salt-call cp.get_file salt://path/to/schema.sql
    /tmp/schema.sql && mysql < /tmp/schema.sql && rm -f /tmp/schema.sql'
       - onlyif: 'some test condition'



    Tanoti wrote:
    I've got a state that needs to do a DB schema import using cmd.run and
    I would like to have salt pull the schema file from the master and use
    it as the redirected-in argument on the command. However, I would like
    to do this so the file is treated as a temporary one and removed after
    the import. I know I could do file.managed to /tmp, cmd.run using that
    file then file.absent to remove it but I wonder is there a way to use
    a file from the master directly (maybe via the minion cache)?

    Regards,
    John
    --
    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.
  • Tanoti at Jul 9, 2014 at 12:57 pm
    Thanks but that is basically doing the same as the three states I described
    in my question. What I would like to know is if there is a way in a state
    file to specify a file as a salt-master sourced object so that it is pulled
    over from the master and the cache location filename is used in the command?

    John

    --
    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 Jul 9, 2014 at 6:46 pm
    Hi John,

    Tanoti wrote:
    Thanks but that is basically doing the same as the three states I
    described in my question.
    It's not doing the same as the three states you described.
    In your case the file.managed would always create the temporary file,
    file.absent would delete it afterwards. That would happen on every
    state.highstate run. Even on runs that do not need that file because you
    do not need to run the cmd.run state. file.managed and file.absent do
    not have the onlyif / unless keywords that cmd.run has. If the file is
    rather big this could make a significant difference.
    What I would like to know is if there is a way in a state file to
    specify a file as a salt-master sourced object so that it is pulled
    over from the master and the cache location filename is used in the
    command?
    Caching 'salt://' files on the minion can be done via
    http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.cp.html#salt.modules.cp.cache_file
    . After that you should be able to find the cached files in
    /var/cache/salt/minion/files/. Since cp.cache_fileis a salt module, not
    a salt state, you need to use
    http://docs.saltstack.com/en/latest/ref/states/all/salt.states.module.html
    to incorporate it into a formula.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedJul 9, '14 at 11:56a
activeJul 9, '14 at 6:46p
posts4
users2

2 users in discussion

Daniel Jagszent: 2 posts Tanoti: 2 posts

People

Translate

site design / logo © 2022 Grokbase