FAQ
Hi,

   I have two custom Salt output modules that share 90% of the code.

My questions:
  - What is the proper way to reuse the code ?
  - Is there a way to create an load a custom salt utils module ?
  - How can I import another file inside a Salt output module

Thanks,
   Julian

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

  • Colton Myers at Aug 26, 2015 at 6:41 pm
    You can sync custom utils modules via the `_utils` folder in your
    file_roots (/srv/salt/_utils/ by default).

    salt '*' saltutil.sync_utils

    That's probably your best bet.

    --
    Colton Myers
    Core Engineer, SaltStack
    @basepi on Twitter/Github/IRC
    On Fri, Aug 21, 2015 at 7:46 AM, Iulian Ghionoiu wrote:

    Hi,

    I have two custom Salt output modules that share 90% of the code.

    My questions:
    - What is the proper way to reuse the code ?
    - Is there a way to create an load a custom salt utils module ?
    - How can I import another file inside a Salt output module

    Thanks,
    Julian

    --
    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.
  • Florian Ermisch at Aug 26, 2015 at 7:26 pm
    Related question: Is it possible to use modules/functions from _utils in py-rendered statefiles?
    Tried this a few days ago but couldn't make it work. Do I have to wrap them in exec modules?

    Regards, Florian

    Am 26. August 2015 20:41:01 MESZ, schrieb Colton Myers <colton.myers@gmail.com>:
    You can sync custom utils modules via the `_utils` folder in your
    file_roots (/srv/salt/_utils/ by default).

    salt '*' saltutil.sync_utils

    That's probably your best bet.

    --
    Colton Myers
    Core Engineer, SaltStack
    @basepi on Twitter/Github/IRC

    On Fri, Aug 21, 2015 at 7:46 AM, Iulian Ghionoiu <
    iuli.constantin.ro@gmail.com> wrote:
    Hi,

    I have two custom Salt output modules that share 90% of the code.

    My questions:
    - What is the proper way to reuse the code ?
    - Is there a way to create an load a custom salt utils module ?
    - How can I import another file inside a Salt output module

    Thanks,
    Julian

    --
    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.
  • Iulian Ghionoiu at Aug 27, 2015 at 3:48 pm
    Thanks for the suggestion.

    How do you import a custom utils module inside a custom output module ?
    On Wednesday, August 26, 2015 at 7:41:23 PM UTC+1, basepi wrote:

    You can sync custom utils modules via the `_utils` folder in your
    file_roots (/srv/salt/_utils/ by default).

    salt '*' saltutil.sync_utils

    That's probably your best bet.

    --
    Colton Myers
    Core Engineer, SaltStack
    @basepi on Twitter/Github/IRC

    On Fri, Aug 21, 2015 at 7:46 AM, Iulian Ghionoiu <iuli.cons...@gmail.com
    <javascript:>> wrote:
    Hi,

    I have two custom Salt output modules that share 90% of the code.

    My questions:
    - What is the proper way to reuse the code ?
    - Is there a way to create an load a custom salt utils module ?
    - How can I import another file inside a Salt output module

    Thanks,
    Julian

    --
    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.
  • Colton Myers at Sep 1, 2015 at 5:45 pm
    Custom util modules are loaded into a special `__utils__` variable in
    modules. It's possible we don't have it loading into output modules, so if
    it doesn't work open an issue, ping me (@basepi) and we'll get it added.

    Florian: should be doable but we might not be loading them into the py
    renderer. Same as above, if __utils__ doesn't work, we should be able to
    get it added.

    --
    Colton Myers
    Core Engineer, SaltStack
    @basepi on Twitter/Github/IRC
    On Thu, Aug 27, 2015 at 9:48 AM, Iulian Ghionoiu wrote:

    Thanks for the suggestion.

    How do you import a custom utils module inside a custom output module ?
    On Wednesday, August 26, 2015 at 7:41:23 PM UTC+1, basepi wrote:

    You can sync custom utils modules via the `_utils` folder in your
    file_roots (/srv/salt/_utils/ by default).

    salt '*' saltutil.sync_utils

    That's probably your best bet.

    --
    Colton Myers
    Core Engineer, SaltStack
    @basepi on Twitter/Github/IRC

    On Fri, Aug 21, 2015 at 7:46 AM, Iulian Ghionoiu <iuli.cons...@gmail.com>
    wrote:
    Hi,

    I have two custom Salt output modules that share 90% of the code.

    My questions:
    - What is the proper way to reuse the code ?
    - Is there a way to create an load a custom salt utils module ?
    - How can I import another file inside a Salt output module

    Thanks,
    Julian

    --
    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+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 @
postedAug 21, '15 at 1:46p
activeSep 1, '15 at 5:45p
posts5
users3

People

Translate

site design / logo © 2022 Grokbase