On 5/23/14 10:10 PM, Colton Myers wrote:
> If you are providing a grain with the correct master, then you're still
> providing custom data on that minion, so why not just provide it in the
> minion config? If you didn't want to edit the actual minion config, you
> could just throw a file in `/etc/salt/minion.d/` with the master IP in
> it, and it will be picked up when the minion starts.
>
> Or am I missing something?
I'm afraid so :-)
My goal is, to have something on the minions with which i can manage the
masters ip dynamically. I think an example makes it more clear.
I want a minion to calculate its master-ip upon start. If i would do it
with a module, that would be something like
minion_funcs.get_master_ip()
the function get_master_ip() takes for example the minions hostname and
does (all pseudo-code):
###
hostname = socket.gethostname()
if hostname.startswith('web'):
return '10.10.10.10'
elif hostname.startswith('db'):
return '10.10.10.11'
####
or the function takes only the digits of the hostname and does:
###
digits = int(re.search('\d+', socket.gethostname()))
if digits > 1000:
return '10.10.10.10'
elif digits > 2000:
return '10.10.10.11'
elif digits > 3000':
return '10.10.10.12'
###
If i would ever want to change the distribution of minions to the
different masters, i would change it in the module, do a sync_modules
and restart the minions.
What i do not want is to have
- config A on minions server0000 - server0999
- config B on minions server1000 - server1999
- config C on minions server2000 - server2999
etc.
that would of course work, but its too static and needs too much
attention if i ever want to change the distribution of minions to the
master.
I hope that makes it more clear.
- felskrone