首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SaltStack晶粒误差

SaltStack晶粒误差
EN

Stack Overflow用户
提问于 2017-05-31 08:26:47
回答 1查看 1K关注 0票数 0

我的盐栈仆从有个奇怪的问题。我在Ubuntu16.04上安装了仆从,到主服务器的连接也很好。但是,当我试图在我的仆从上创建一个state.apply时,我就会得到一个Jinja模板错误:

代码语言:javascript
复制
jenkins01-prod:
      Data failed to compile:
----------
Rendering SLS 'base:salt.minion' failed: Jinja error: coercing to Unicode: need string or buffer, int found
 /var/cache/salt/minion/files/base/salt/map.jinja(43):
 ---
   [...]
 {##
 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):

self._body_stream = list(template.root_render_func(context))
 File "/var/cache/salt/minion/files/base/salt/map.jinja", line 43, in top-level template code
{% set os_family_map = salt['grains.filter_by']({
TypeError: coercing to Unicode: need string or buffer, int found

我查了一下奴才身上的粮食:

代码语言:javascript
复制
  os:
       Ubuntu
   os_family:
       Debian
   osarch:
       amd64
   oscodename:
       xenial
   osfinger:
       Ubuntu-16.04
   osfullname:
       Ubuntu
   osmajorrelease:
       16
   osrelease:
       16.04
   osrelease_info:
       - 16
       - 4

主机是EC2实例,在具有相同设置的另一个主机上运行良好。随附您找到的盐版本-报告:盐版本:

代码语言:javascript
复制
         Salt: 2017.5.0-191-gb43b89c

 Dependency Versions:
       cffi: Not Installed
   cherrypy: Not Installed
   dateutil: 2.4.2
  docker-py: Not Installed
      gitdb: Not Installed
  gitpython: Not Installed
      ioflo: Not Installed
     Jinja2: 2.8
    libgit2: Not Installed
    libnacl: Not Installed
   M2Crypto: Not Installed
       Mako: 1.0.3
  msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
  pycparser: Not Installed
   pycrypto: 2.6.1
pycryptodome: Not Installed
     pygit2: Not Installed
     Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
     PyYAML: 3.11
      PyZMQ: 15.2.0
       RAET: Not Installed
      smmap: Not Installed
    timelib: Not Installed
    Tornado: 4.2.1
        ZMQ: 4.1.4

  System Versions:
       dist: Ubuntu 16.04 xenial
    machine: x86_64
    release: 4.4.0-78-generic
     system: Linux
    version: Ubuntu 16.04 xenial
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-31 16:18:12

在最近的盐分版本中,osmajorrelease谷物从字符串转换为整数(https://github.com/saltstack/salt/issues/35972)。您所得到的错误是,您的Jinja模板需要字符串,但是获得了整数( TypeError: coercing to Unicode: need string or buffer, int found )。

我不知道在状态内到底做了什么,但是解决这个问题的一种方法是将整数转换为.jinja文件中的字符串。例如:

代码语言:javascript
复制
{% set osrelease = salt['grains.get']('osrelease')|string %}

希望这能有所帮助!

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44279484

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档