Skip to content

Instantly share code, notes, and snippets.

@rca
Created May 24, 2013 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rca/5646896 to your computer and use it in GitHub Desktop.
Save rca/5646896 to your computer and use it in GitHub Desktop.
Salt mine always returning data belonging to the salt master

Created mine.sls pillar:

#!py

def run():
    return {
        'mine_interval': 60,
        'mine_functions': {
            'network.interfaces': [],
            'test.ping': [],
        },
    }

Restarted minions

salt '*' cmd.run 'service salt-minion restart'

Try to get network information, for example:

{% for hostname, host_info in salt['mine.get']('*', 'network.interfaces').items() %}
{% set interface = host_info['p4p1'] %}
host {{ hostname }} {
  hardware ethernet {{ interface['hwaddr'] }};
  fixed-address {{ interface['inet'][0]['address'] }};
  [...]
}
{% endfor %}

The above example renders master's data for all hosts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment