Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jinja2 scripting reclass w/SaltStack #6

Closed
inthecloud247 opened this issue Jul 23, 2013 · 5 comments
Closed

jinja2 scripting reclass w/SaltStack #6

inthecloud247 opened this issue Jul 23, 2013 · 5 comments

Comments

@inthecloud247
Copy link

@inthecloud247 inthecloud247 commented Jul 23, 2013

In the readme.Salt file, you mention that "Jinja2-style variables in parameter
values" are currently not working?

Seems like this works with reclass + Ansible currently. Is there anything still blocking reclass + jinja2 with Saltstack?

@madduck
Copy link
Owner

@madduck madduck commented Jul 23, 2013

Yeah, it "works" with Ansible because Ansible itself does Jinja-templating on the variable values, but in doing so it converts everything to strings and loses the type. Having pointed out this issue on the list, I was subsequently kicked out of the community and couldn't send another message (see below). Obviously, the way Ansible does it is not acceptable, but the author doesn't get it.

I am working on interpolation inside reclass, but I am not yet done. Give me another week or two. It'll be much better than what Ansible can do.

Here's my message to the list, which was censored:

Date: Sun, 23 Jun 2013 20:36:21 +0200
From: martin f krafft <madduck@madduck.net>
To: "ansible-project@googlegroups.com" <ansible-project@googlegroups.com>
Subject: Re: [ansible-project] Re: Preserving list objects with Jinja2-style variables

> Types in the playbooks don't matter because all the necessary
> casting happens in the modules.

Try it with 'template':

  ---
  - name: test playbook
    hosts: test_hosts
    gather_facts: no
    vars:
      mylist:
        - 1
        - 2
        - 3
      othervar: '{{mylist}}'
      escaped: \{{mylist}}
      yesno: yes
      notboolean: '{{yesno}}'
    tasks:
      - template: src=test.j2 dest=/tmp/out

And test.j2 just has

  {{mylist.__class__}} {{othervar.__class__}} {{escaped.__class__}}
  {{yesno.__class__}} {{notboolean.__class__}}

in it. You will see that the types are (list, unicode, unicode,
bool, unicode), so there is no casting, actually; the list and
boolean are lost. Everything is converted to unicode, and there is
no way a module can cast that back. Sorry.
@madduck
Copy link
Owner

@madduck madduck commented Jul 23, 2013

Oh, btw, I will not add Jinja2 templating to reclass, just pure variable interpolation. This is because Jinja2 itself casts everything to a string, which you don't want (e.g. lists…)

@madduck
Copy link
Owner

@madduck madduck commented Aug 7, 2013

This is now implemented, and I hope it works. It would be awesome if you could poke at it, and possibly suggest improvements to the documentation. Please let me know anything else that comes to your mind.

@madduck madduck closed this Aug 7, 2013
@madduck
Copy link
Owner

@madduck madduck commented Nov 26, 2013

@inthecloud247
Copy link
Author

@inthecloud247 inthecloud247 commented Nov 26, 2013

Ah cool will take a look. Sorry missed this b4.

On Nov 26, 2013, at 1:31 PM, "martin f. krafft" notifications@github.com wrote:

FTR: http://reclass.pantsfullofunix.net/


Reply to this email directly or view it on GitHub.

AndrewPickford pushed a commit to AndrewPickford/reclass that referenced this issue Sep 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.