Using salt-mine in pillar data

656 views
Skip to first unread message

Kai H

unread,
Dec 23, 2015, 9:03:39 AM12/23/15
to Salt-users
Hi,

I tried using salt mine in pillar data and could not get it working. Is there any architectural reason why it should not work?

pillar/nagios/init.sls
---
nagios:
  nrpe:
    something_else: True
    allowed_hosts:
      {%- for minion, addresses in salt['mine.get']('G@roles:nagios_server', 'ipv4_addresses', 'compound').items() %}
      - {{addresses[0]}}
      {%- endfor %}
---

After saltutil.refresh_pillar, mine.update and a local salt-call as well as usual salt cli for "pillar.get nagios", I will always get:

nagios:
  nrpe:
    something_else: True
    allowed_hosts: None

When running salt-call mine.get 'G@roles:nagios_server' 'ipv4_addresses'  'compound', I get the expected results akin to:

local:
    ----------
    minion-name-1:
        - 10.111.8.196
        - 127.0.0.1
        - 172.17.42.1
        - 192.168.122.1
    minion-name-2:
        - 10.111.8.181
        - 127.0.0.1

For completeness:

pillar/saltmine/init.sls
---
mine_functions:
  ipv4_addresses:
    mine_function: grains.get
    key: ipv4
---

Versions Report:

Salt Version:
           Salt: 2015.8.1

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: 0.21.1
           Mako: 0.9.1
         PyYAML: 3.10
          PyZMQ: 14.0.1
         Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
           RAET: Not Installed
        Tornado: 4.3
            ZMQ: 4.0.4
           cffi: 0.8.2
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: Not Installed
      pycparser: 2.10
       pycrypto: 2.6.1
         pygit2: 0.23.0
   python-gnupg: Not Installed
          smmap: 0.8.2
        timelib: Not Installed

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 3.13.0-53-generic
         system: Ubuntu 14.04 trusty

Seth House

unread,
Dec 23, 2015, 2:21:09 PM12/23/15
to salt users list
You can access Mine data from Pillar. There was a recent documentation
change explaining how but it looks like the development docs for the
mine module are currently broken so I'll link to the pull req instead:

https://github.com/saltstack/salt/pull/27096/files

tl;dr: Pillar is generated on the Master so you need to call the Mine
Runner instead of the Mine Execution module. Syntax looks like this:

{% set minion_ips = salt.saltutil.runner('mine.get',
tgt='*',
fun='network.ip_addrs',
tgt_type='glob') %}
Reply all
Reply to author
Forward
0 new messages