Exception when using Salt mine from pillar
See original GitHub issue$ 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)
Issue Analytics
- State:
- Created 9 years ago
- Comments:56 (37 by maintainers)
Top Results From Across the Web
salt.modules.mine - Salt Project Documentation
Note that all pillar matches, whether using the compound matching system or the pillar matching system, will be exact matches, with globbing disabled....
Read more >mine.get not returning value in pillar (using pillar stack)
Mine seems to have the data I want. Also fine via salt master (same machine, but I thought it worth checking) # salt-run...
Read more >salt-run state.orch ceph.stage.3 fails with: "Module ... - SUSE
3 fails with: "Module function osd.deploy threw an exception. Exception: Missing device /dev/sdm in the Salt mine for cephdisks.list. Try ...
Read more >Using salt-mine in pillar data - Google Groups
Hi,. I tried using salt mine in pillar data and could not get it working. Is there any architectural reason why it should...
Read more >SaltStack - mine.get is able to grab correct mine_function data ...
... some config files and move this to Pillar/Mine data using Salt-Stack. Everything is going well, with the exception of 1 specific task....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
fun
argument which the mine runner uses.regarding https://github.com/saltstack/salt/issues/11509#issuecomment-138980156:
incase anyone is having the same problem - if you have minions that require a significant amount of mine data, this method will timeout (saltReqTimeoutError) when the minion runs state.highstate.
until mine data becomes available in pillar, a hack is to cache the mine data on cron on the salt master. this is detailed here: https://github.com/saltstack/salt/issues/21403#issuecomment-172723015