salt: Exception when using Salt mine from pillar
$ salt 'apt-mirror' state.highstate
apt-mirror:
Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Rendering SLS 'apt-repo.eu-west-1' failed, render error:
Jinja error: 'master_uri'
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/salt/utils/templates.py", line 261, in render_jinja_tmpl
output = jinja_env.from_string(tmplstr).render(**unicode_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 894, in render
return self.environment.handle_exception(exc_info, True)
File "<template>", line 1, in top-level template code
File "/usr/lib/pymodules/python2.7/salt/modules/mine.py", line 182, in get
auth = _auth()
File "/usr/lib/pymodules/python2.7/salt/modules/mine.py", line 24, in _auth
__context__['auth'] = salt.crypt.SAuth(__opts__)
File "/usr/lib/pymodules/python2.7/salt/crypt.py", line 502, in __init__
self.crypticle = self.__authenticate()
File "/usr/lib/pymodules/python2.7/salt/crypt.py", line 514, in __authenticate
self.opts.get('_safe_auth', True)
File "/usr/lib/pymodules/python2.7/salt/crypt.py", line 345, in sign_in
if self.opts['master_ip'] not in self.opts['master_uri']:
KeyError: 'master_uri'
; line 1
---
{% set ipaddrs = salt['mine.get']('apt-mirror', 'network.ipaddrs')[0] %} <======================
{% if ipaddrs %}
apt-repo: http://{{ ipaddrs[0] }}
{% else %}
apt-repo: http://packages.somewhere.com
{% endif %}
[...]
---
This works:
$ salt 'apt-mirror' mine.get apt-mirror network.ipaddrs
apt-mirror:
----------
(no, I wasn’t expecting any data, nor an exception)
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 56 (37 by maintainers)
@AusIV that is a good workaround.
In answer to your question about avoiding the shell-out process: the following should be possible now that #26648 is slated for the next 2015.5.6 point-release and the impending 2015.8 release:
It uses the old-ish but not well-known saltutil.runner function. Unfortunately, prior to the above pull req, it shadowed the
funargument which the mine runner uses.