FAQ
We are trying to use a python renderer to get text_field data using a API:

def run():
     '''
     API Renderer
     '''
     id_host = __grains__['id']

     data = get_api_date(id_host)

     return {
         'data': data
     }


We can see the data in the pillar.items properly:

data:
   text_field:
     # multiline example text
     # we want to use this in a file managed
     parameter1 = 1
     parameter2 = 2


When we use the field in a template rendering:
{% set data = pillar['data'] %}
configuration-file:
     file.managed:
         - name: {{data['filename']}}
         - source: {{ template }}
         - template: jinja
         - context: {{data}}

The result is:
# multiline example text\r\n # we want to use this in a file managed
\r\n parameter1 = 1\r\n parameter2 = 2

We know the method to pass multiline in
context: https://github.com/saltstack/salt/issues/5480, but note the data
dictionary is big and we can't use it,

Any ideas about how to solve this issue?
Thank you



--
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 Apr 22, 2015 at 9:34 pm
    You might consider using a different renderer than the YAML renderer. For
    example, you could use the python renderer and just construct the state
    data structure yourself, and then it shouldn't matter what the `data` looks
    like, you should be able to pass it into `context` just fine.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC
    On Thu, Apr 16, 2015 at 4:54 AM, Edu Herraiz wrote:

    We are trying to use a python renderer to get text_field data using a API:

    def run():
    '''
    API Renderer
    '''
    id_host = __grains__['id']

    data = get_api_date(id_host)

    return {
    'data': data
    }


    We can see the data in the pillar.items properly:

    data:
    text_field:
    # multiline example text
    # we want to use this in a file managed
    parameter1 = 1
    parameter2 = 2


    When we use the field in a template rendering:
    {% set data = pillar['data'] %}
    configuration-file:
    file.managed:
    - name: {{data['filename']}}
    - source: {{ template }}
    - template: jinja
    - context: {{data}}

    The result is:
    # multiline example text\r\n # we want to use this in a file managed
    \r\n parameter1 = 1\r\n parameter2 = 2

    We know the method to pass multiline in context:
    https://github.com/saltstack/salt/issues/5480, but note the data
    dictionary is big and we can't use it,

    Any ideas about how to solve this issue?
    Thank you



    --
    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.
  • Edu Herraiz at Apr 25, 2015 at 8:31 am
    Rewriting the same states definition using the pyhon renderer solves the
    problem!!
    Thank you!

    El miércoles, 22 de abril de 2015, 23:34:36 (UTC+2), basepi escribió:
    You might consider using a different renderer than the YAML renderer. For
    example, you could use the python renderer and just construct the state
    data structure yourself, and then it shouldn't matter what the `data` looks
    like, you should be able to pass it into `context` just fine.

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

    On Thu, Apr 16, 2015 at 4:54 AM, Edu Herraiz <gsh...@gmail.com
    <javascript:>> wrote:
    We are trying to use a python renderer to get text_field data using a API:

    def run():
    '''
    API Renderer
    '''
    id_host = __grains__['id']

    data = get_api_date(id_host)

    return {
    'data': data
    }


    We can see the data in the pillar.items properly:

    data:
    text_field:
    # multiline example text
    # we want to use this in a file managed
    parameter1 = 1
    parameter2 = 2


    When we use the field in a template rendering:
    {% set data = pillar['data'] %}
    configuration-file:
    file.managed:
    - name: {{data['filename']}}
    - source: {{ template }}
    - template: jinja
    - context: {{data}}

    The result is:
    # multiline example text\r\n # we want to use this in a file managed
    \r\n parameter1 = 1\r\n parameter2 = 2

    We know the method to pass multiline in context:
    https://github.com/saltstack/salt/issues/5480, but note the data
    dictionary is big and we can't use it,

    Any ideas about how to solve this issue?
    Thank you



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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedApr 16, '15 at 10:54a
activeApr 25, '15 at 8:31a
posts3
users2

2 users in discussion

Edu Herraiz: 2 posts Colton Myers: 1 post

People

Translate

site design / logo © 2022 Grokbase