FAQ
Hello fellow salt users,

I am setting some defaults on the map.jinja basicaly every attribute
is checked if it given on the pillar data, like:

{% set my_param = pillar["myformula"]["my_param"] %}

{# or #}

{% set my_param = "mydeafultvalue" %}

But this gets old very fast and i would like basically declare this in a
simpler way. I may be talking out of my arse but something like this
would be beautiful.

{% set defaults = {
   "myparam1": "mydefaul1",
   "myparam2": "mydefaul2"
   "myparam3": "mydefaul3"
} %}

And them somehow check for the pillar the ["myformula"] yaml namespace
check for parameters, if some of them does not exist use the one in the
defaults table.

Any sugestions welcome.

--
Regards,
Alfredo Palhares

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

  • Arnold Bechtoldt at Aug 15, 2014 at 6:06 pm
    I don't understand what you try to achieve. Could you give me another
    example?

    See <https://github.com/bechtoldt/postfix-formula> if you're interested
    in how my own formulas look like. The structure is a bit different
    compared to the recommended one in the docs.


    Arnold

    --
    Arnold Bechtoldt

    Karlsruhe, Germany
    On 14.08.14 16:38, Alfredo Palhares wrote:
    Hello fellow salt users,

    I am setting some defaults on the map.jinja basicaly every attribute
    is checked if it given on the pillar data, like:

    {% set my_param = pillar["myformula"]["my_param"] %}

    {# or #}

    {% set my_param = "mydeafultvalue" %}

    But this gets old very fast and i would like basically declare this in a
    simpler way. I may be talking out of my arse but something like this
    would be beautiful.

    {% set defaults = {
    "myparam1": "mydefaul1",
    "myparam2": "mydefaul2"
    "myparam3": "mydefaul3"
    } %}

    And them somehow check for the pillar the ["myformula"] yaml namespace
    check for parameters, if some of them does not exist use the one in the
    defaults table.

    Any sugestions welcome.

    --
    Regards,
    Alfredo Palhares
  • Seth House at Aug 15, 2014 at 8:45 pm

    On Aug 14, 2014 10:38 AM, "Alfredo Palhares" wrote:
    And them somehow check for the pillar the ["myformula"] yaml namespace
    check for parameters, if some of them does not exist use the one in the
    defaults table.

    Any sugestions welcome.
    How about something like this?

    {% set defaults = {
       "myparam1": "mydefaul1",
       "myparam2": "mydefaul2"
       "myparam3": "mydefaul3"
    } %}
    {% do defaults.update(pillar.get('myformula') %}

    That allows you to declare all defaults inline and optionally override any
    values via Pillar.

    All values will be available as:

    {{ defaults.myparam1 }}

    --
    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 15, 2014 at 8:46 pm
    Pardon the missing paren. I'm typing on my phone. :-P
    On Aug 15, 2014 4:45 PM, "Seth House" wrote:
    On Aug 14, 2014 10:38 AM, "Alfredo Palhares" wrote:
    And them somehow check for the pillar the ["myformula"] yaml namespace
    check for parameters, if some of them does not exist use the one in the
    defaults table.

    Any sugestions welcome.
    How about something like this?

    {% set defaults = {
    "myparam1": "mydefaul1",
    "myparam2": "mydefaul2"
    "myparam3": "mydefaul3"
    } %}
    {% do defaults.update(pillar.get('myformula') %}

    That allows you to declare all defaults inline and optionally override any
    values via Pillar.

    All values will be available as:

    {{ defaults.myparam1 }}
    --
    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.
  • Alfredo Palhares at Aug 18, 2014 at 9:18 am

    Excerpts from Seth House's message of 2014-08-15 22:45:10 +0200:
    {% set defaults = {
    "myparam1": "mydefaul1",
    "myparam2": "mydefaul2"
    "myparam3": "mydefaul3"
    } %}
    {% do defaults.update(pillar.get('myformula') %}
    I discovery this marvelous update method on friday this is what I want.


    Excerpts from Arnold Bechtoldt's message of 2014-08-15 20:05:59 +0200:
    I don't understand what you try to achieve. Could you give me another
    example?

    See <https://github.com/bechtoldt/postfix-formula> if you're
    interested
    in how my own formulas look like. The structure is a bit different
    compared to the recommended one in the docs.
    I find this approach interesting and very easy to read, jinja
    documentation seems very sparse. Do rawmaps allow to be overrideen by
    pillar data with the update function? If so, these will be a much more
    readable alternative.


    Thank you so much for you input!

    --
    Regards,
    Alfredo Palhares

    --
    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 14, '14 at 2:38p
activeAug 18, '14 at 9:18a
posts5
users3

People

Translate

site design / logo © 2022 Grokbase