FAQ
Hi Guy,

I run into a strange bug. I have two machine. Both of them are Ubuntu OS.
salt-master: ubuntu 14.04 192.168.1.213

salt-master# salt-call --versions-report
            Salt: 2014.1.7
          Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
          Jinja2: 2.7.2
        M2Crypto: 0.21.1
  msgpack-python: 0.3.0
    msgpack-pure: Not Installed
        pycrypto: 2.6.1
          PyYAML: 3.10
           PyZMQ: 14.0.1
             ZMQ: 4.0.4

salt-minion: ubuntu 12.04 192.168.0.208

salt-minion# salt-call --versions-report
            Salt: 2014.1.7
          Python: 2.7.3 (default, Aug 1 2012, 05:14:39)
          Jinja2: 2.6
        M2Crypto: 0.21.1
  msgpack-python: 0.3.0
    msgpack-pure: Not Installed
        pycrypto: 2.6.1
          PyYAML: 3.10
           PyZMQ: 13.0.0
             ZMQ: 3.2.2

I want to use get_or_set_hash to generate password used by minion. So I add
following pillar file.

z0: {{ salt["grains.get_or_set_hash"]("test2") }}

Then I try to get the pillar.items

salt-master# salt -v -t 6000 'salt-minion' pillar.items

But failed and raise following error

_errors:
         - Rendering SLS 'test' failed, render error:
         - Jinja error: 'master_uri'
         - Traceback (most recent call last):
         - File
"/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 263,
in render_jinja_tmpl
         - output = jinja_env.from_string(tmplstr).render(**unicode_context)
         - File
"/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in
render
         - return self.environment.handle_exception(exc_info, True)
         - File
"/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 742, 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/salt/modules/grains.py", line 441,
in get_or_set_hash
         - setval(name, val)
         - File
"/usr/lib/python2.7/dist-packages/salt/modules/grains.py", line 216,
in setval
         - __salt__['saltutil.sync_grains']()
         - File
"/usr/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 266,
in sync_grains
         - ret = _sync('grains', saltenv)
         - File
"/usr/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 73,
in _sync
         - saltenv = _get_top_file_envs()
         - File
"/usr/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 54,
in _get_top_file_envs
         - st_ = salt.state.HighState(__opts__)
         - File "/usr/lib/python2.7/dist-packages/salt/state.py",
line 2598, in __init__
         - self.client = salt.fileclient.get_file_client(opts)
         - File
"/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 42, in
get_file_client
         - }.get(opts['file_client'], RemoteClient)(opts)
         - File
"/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 838, in
__init__
         - self.channel = salt.transport.Channel.factory(self.opts)
         - File
"/usr/lib/python2.7/dist-packages/salt/transport/__init__.py", line
24, in factory
         - return ZeroMQChannel(opts, **kwargs)
         - File
"/usr/lib/python2.7/dist-packages/salt/transport/__init__.py", line
50, in __init__
         - self.auth = salt.crypt.SAuth(opts)
         - File "/usr/lib/python2.7/dist-packages/salt/crypt.py",
line 519, in __init__
         - self.crypticle = self.__authenticate()
         - File "/usr/lib/python2.7/dist-packages/salt/crypt.py",
line 531, in __authenticate
         - self.opts.get('_safe_auth', True)
         - File "/usr/lib/python2.7/dist-packages/salt/crypt.py",
line 353, in sign_in
         - if self.opts['master_ip'] not in self.opts['master_uri']:
         - KeyError: 'master_uri'
         -
         - ; line 1

         - ---
         - z0: {{ salt["grains.get_or_set_hash"]("test2") }}
<======================
         -
         - Traceback (most recent call last):
         - File
"/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 263,
in render_jinja_tmpl
         - output = jinja_env.from_string(tmplstr).render(**unicode_context)
         - File
"/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in
render
         - [...]
         - ---


The most wired thing it that, on the salt-master, salt generate the grains
file in /etc/salt/grains, which I
think should be generate on salt-minion

test2: r*!%q)y1

If I run following command. The grains file will be created on the
salt-minion as ecpected.

salt-master# alt -v -t 6000 'salt-minion' grains.get_or_set_hash test2

Is anybody meet this and know how to fixed it?

--
Lei Zhang
Blog: http://xcodest.me
twitter/weibo: @jeffrey4l

--
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 Aug 15, 2014 at 10:55 pm
    So the issue here is that `salt[]` functions run inside of pillar sls files
    are executed on the master, not the minion, because the master is
    generating the pillar without minion interaction. So you can't use this
    function from inside of pillar, unfortunately.

    I think you'll have to set this on the command line as a normal command to
    the minion, and then use `graings['test2']` instead, as pillar does have
    access to the cached minion grains when it's being generated.

    --
    Colton Myers

    On Thu, Jul 31, 2014 at 1:29 AM, Lei Zhang wrote:

    Hi Guy,

    I run into a strange bug. I have two machine. Both of them are Ubuntu OS.
    salt-master: ubuntu 14.04 192.168.1.213

    salt-master# salt-call --versions-report
    Salt: 2014.1.7
    Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
    Jinja2: 2.7.2
    M2Crypto: 0.21.1
    msgpack-python: 0.3.0
    msgpack-pure: Not Installed
    pycrypto: 2.6.1
    PyYAML: 3.10
    PyZMQ: 14.0.1
    ZMQ: 4.0.4

    salt-minion: ubuntu 12.04 192.168.0.208

    salt-minion# salt-call --versions-report
    Salt: 2014.1.7
    Python: 2.7.3 (default, Aug 1 2012, 05:14:39)
    Jinja2: 2.6
    M2Crypto: 0.21.1
    msgpack-python: 0.3.0
    msgpack-pure: Not Installed
    pycrypto: 2.6.1
    PyYAML: 3.10
    PyZMQ: 13.0.0
    ZMQ: 3.2.2

    I want to use get_or_set_hash to generate password used by minion. So I
    add following pillar file.

    z0: {{ salt["grains.get_or_set_hash"]("test2") }}

    Then I try to get the pillar.items

    salt-master# salt -v -t 6000 'salt-minion' pillar.items

    But failed and raise following error

    _errors:
    - Rendering SLS 'test' failed, render error:
    - Jinja error: 'master_uri'
    - Traceback (most recent call last):
    - File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 263, in render_jinja_tmpl
    - output = jinja_env.from_string(tmplstr).render(**unicode_context)
    - File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in render
    - return self.environment.handle_exception(exc_info, True)
    - File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 742, 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/salt/modules/grains.py", line 441, in get_or_set_hash
    - setval(name, val)
    - File "/usr/lib/python2.7/dist-packages/salt/modules/grains.py", line 216, in setval
    - __salt__['saltutil.sync_grains']()
    - File "/usr/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 266, in sync_grains
    - ret = _sync('grains', saltenv)
    - File "/usr/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 73, in _sync
    - saltenv = _get_top_file_envs()
    - File "/usr/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 54, in _get_top_file_envs
    - st_ = salt.state.HighState(__opts__)
    - File "/usr/lib/python2.7/dist-packages/salt/state.py", line 2598, in __init__
    - self.client = salt.fileclient.get_file_client(opts)
    - File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 42, in get_file_client
    - }.get(opts['file_client'], RemoteClient)(opts)
    - File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 838, in __init__
    - self.channel = salt.transport.Channel.factory(self.opts)
    - File "/usr/lib/python2.7/dist-packages/salt/transport/__init__.py", line 24, in factory
    - return ZeroMQChannel(opts, **kwargs)
    - File "/usr/lib/python2.7/dist-packages/salt/transport/__init__.py", line 50, in __init__
    - self.auth = salt.crypt.SAuth(opts)
    - File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 519, in __init__
    - self.crypticle = self.__authenticate()
    - File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 531, in __authenticate
    - self.opts.get('_safe_auth', True)
    - File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 353, in sign_in
    - if self.opts['master_ip'] not in self.opts['master_uri']:
    - KeyError: 'master_uri'
    -
    - ; line 1

    - ---
    - z0: {{ salt["grains.get_or_set_hash"]("test2") }} <======================
    -
    - Traceback (most recent call last):
    - File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 263, in render_jinja_tmpl
    - output = jinja_env.from_string(tmplstr).render(**unicode_context)
    - File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in render
    - [...]
    - ---


    The most wired thing it that, on the salt-master, salt generate the grains
    file in /etc/salt/grains, which I
    think should be generate on salt-minion

    test2: r*!%q)y1

    If I run following command. The grains file will be created on the
    salt-minion as ecpected.

    salt-master# alt -v -t 6000 'salt-minion' grains.get_or_set_hash test2

    Is anybody meet this and know how to fixed it?

    --
    Lei Zhang
    Blog: http://xcodest.me
    twitter/weibo: @jeffrey4l

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedJul 31, '14 at 7:29a
activeAug 15, '14 at 10:55p
posts2
users2

2 users in discussion

Lei Zhang: 1 post Colton Myers: 1 post

People

Translate

site design / logo © 2022 Grokbase