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

"osmajorrelease grain has been changed from a string to an integer" #324

Closed
willxy opened this issue Jul 25, 2017 · 2 comments
Closed

"osmajorrelease grain has been changed from a string to an integer" #324

willxy opened this issue Jul 25, 2017 · 2 comments

Comments

@willxy
Copy link

willxy commented Jul 25, 2017

From the salt 2017.7.0 'nitrogen' release notes:

GRAINS CHANGES

  • The osmajorrelease grain has been changed from a string to an integer. State files, especially those using a templating language like Jinja, may need to be adjusted to account for this change.

I ran into this with errors from salt-formula/salt/map.jinja:

[ERROR   ] Rendering exception occurred: Jinja error: coercing to Unicode: need string or buffer, int found
/var/cache/salt/minion/files/base/salt/map.jinja(12):
---
[...]
{##
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 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/latest ' + salt['grains.get']('oscodename') + ' main',
      'key_url': 'https://repo.saltstack.com/apt/' + salt['grains.get']('os')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease) + '/amd64/latest/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 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 780, 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 1073, in make_module
    return TemplateModule(self, self.new_context(vars, shared, locals))
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 1152, in __init__
    body_stream = list(template.root_render_func(context))
  File "/var/cache/salt/minion/files/base/salt/map.jinja", line 12, in top-level template code
    {% set os_family_map = salt['grains.filter_by']({
TypeError: coercing to Unicode: need string or buffer, int found

Changing references in salt-formula/salt/map.jinja from:

salt['grains.get']('osmajorrelease', osrelease)

to:

salt['grains.get']('osmajorrelease', osrelease)|string

seemed to have it work.

@aboe76
Copy link
Member

aboe76 commented Jul 25, 2017

@willxy did #322 fix your issue?

@willxy
Copy link
Author

willxy commented Jul 25, 2017

@aboe76 Indeed it does. Sorry I missed that one earlier. Thank you!

@willxy willxy closed this as completed Jul 25, 2017
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

No branches or pull requests

2 participants