Created
April 10, 2016 21:19
-
-
Save kevinquinnyo/315ea9f00d28d94563b8c170d7ce817c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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