Skip to content

Instantly share code, notes, and snippets.

@kevinquinnyo
Created April 10, 2016 21:19
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 kevinquinnyo/315ea9f00d28d94563b8c170d7ce817c to your computer and use it in GitHub Desktop.
Save kevinquinnyo/315ea9f00d28d94563b8c170d7ce817c to your computer and use it in GitHub Desktop.
#!py
def run():
states = {}
cache_private_ips = __salt__['tss.get_role_ips']('cache')
states['test-tss-module'] = {
'cmd.run': [
{'name': 'echo {0} > /tmp/tss-module-test.txt'.format(cache_private_ips)},
]
}
return states
# -*- coding: utf-8 -*-
'''
Utility module for TSS general purpose functions.
'''
from __future__ import absolute_import
def __virtual__():
return 'tss'
__opts__ = {}
def get_role_ips(role, interface='eth1'):
billing_id = __pillar__['cluster']['client']['billing_id']
cluster_name = __pillar__['cluster']['name']
ips = []
interfaces = __salt__['mine.get']('{0}*{1}-{2}.my-platform-domain.com'.format(role, billing_id, cluster_name), 'network.interfaces')
for minion, interface in interfaces.iteritems():
for name, data in interface.iteritems():
if name == interface:
ips.append(data['inet'][0]['address'])
return ips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment