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

Fix map.jinja to work with 2017.7.0 #322

Merged
merged 1 commit into from
Jul 21, 2017

Conversation

matthew-parlette
Copy link
Contributor

This was to resolve the following error when using this state on 2017.7.0 (with the change to osmajorrelease:

local:
    Data failed to compile:
----------
    Rendering SLS 'base:salt.master' failed: Jinja error: coercing to Unicode: need string or buffer, int found
/var/cache/salt/minion/files/base/salt/map.jinja(44):
---
[...]
Setup variable using grains['os_family'] based logic, only add key:values here
that differ from whats in defaults.yaml
##}
{% set osrelease = salt['grains.get']('osrelease') %}
{% set salt_release = salt['pillar.get']('salt:release', 'latest') %}
{% set os_family_map = salt['grains.filter_by']({    <======================
    'Debian':  {
      'pkgrepo': 'deb http://repo.saltstack.com/apt/' +
      salt['grains.get']('os')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease) + '/amd64/' + salt_release + ' ' + salt['grains.get']('oscodename') + ' main',
      'key_url': 'https://repo.saltstack.com/apt/' + salt['grains.get']('os')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease) + '/amd64/' + salt_release  + '/SALTSTACK-GPG-KEY.pub',
      'libgit2': 'libgit2-22',
[...]
---
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 410, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 1033, in make_module
    return TemplateModule(self, self.new_context(vars, shared, locals))
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 1090, in __init__
    self._body_stream = list(template.root_render_func(context))
  File "/var/cache/salt/minion/files/base/salt/map.jinja", line 44, in top-level template code
    {% set os_family_map = salt['grains.filter_by']({
TypeError: coercing to Unicode: need string or buffer, int found

This has not been tested with earlier salt versions, but I don't see any issue with it.

@aboe76
Copy link
Member

aboe76 commented Jul 18, 2017

Does it still work with older 2016 versions? I have tested a minion, this works.
but no debian 2016 master/minions left...

tested this change with a salt-master 2016.3.6 and a minion 2016.3.6 works.

Copy link
Member

@aboe76 aboe76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested it on 2016.3.6 master/minion

@aboe76 aboe76 requested review from aboe76 and 0xf10e and removed request for aboe76 July 19, 2017 07:29
@snadorp
Copy link

snadorp commented Jul 19, 2017

Can we get a merge? Kinda running into this problem right now. :)

@aboe76
Copy link
Member

aboe76 commented Jul 19, 2017

@snadorp I prefer some more testing on older saltstack versions, because others will look at how to solve this for other formula's, so if you can test 2016.6?

@aboe76 aboe76 requested a review from nmadhok July 20, 2017 07:34
Copy link
Contributor

@0xf10e 0xf10e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine with 2015.5, 2015.8, 2016.3 and 2016.11 on CentOS 7 and Ubuntu 1{2,4,6}.4.
No guarantees for 2016.x on FreeBSD 10.3, archlinux or Windows though.

@0xf10e
Copy link
Contributor

0xf10e commented Jul 21, 2017

Thanks for the fix @matthew-parlette 👍
And sorry for missing the review request @aboe76 ... :/

@0xf10e
Copy link
Contributor

0xf10e commented Jul 21, 2017

@aboe76 merge or are we waiting for @nmadhok's review?

@aboe76
Copy link
Member

aboe76 commented Jul 21, 2017

@0xf10e no if you think it's fine with most salt versions. then please merge.

@aboe76 aboe76 merged commit 96edba2 into saltstack-formulas:master Jul 21, 2017
@aboe76
Copy link
Member

aboe76 commented Jul 21, 2017

done @matthew-parlette

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants