diff --git a/salt/cloud/__init__.py b/salt/cloud/__init__.py index 1cd234e609..a00d609cd5 100644 --- a/salt/cloud/__init__.py +++ b/salt/cloud/__init__.py @@ -251,15 +251,19 @@ class CloudClient(object): mapper = salt.cloud.Map(self._opts_defaults()) return mapper.map_providers_parallel(query_type) - def profile(self, profile, names, **kwargs): + def profile(self, profile, names, vm_opts=None, **kwargs): ''' Pass in a profile to create, names is a list of vm names to allocate + + vm_opts is a spetial dict that will be per node options overrides ''' + if not vm_opts: + vm_opts = {} mapper = salt.cloud.Map(self._opts_defaults(**kwargs)) if isinstance(names, str): names = names.split(',') return salt.utils.cloud.simple_types_filter( - mapper.run_profile(profile, names)) + mapper.run_profile(profile, names, vm_opts=vm_opts)) def destroy(self, names): ''' @@ -1055,7 +1059,7 @@ class Cloud(object): output['ret'] = action_out return output - def run_profile(self, profile, names): + def run_profile(self, profile, names, vm_opts=None): ''' Parse over the options passed on the command line and determine how to handle them @@ -1066,6 +1070,8 @@ class Cloud(object): return {'Error': msg} ret = {} + if not vm_opts: + vm_opts = {} profile_details = self.opts['profiles'][profile] alias, driver = profile_details['provider'].split(':') mapped_providers = self.map_providers_parallel() @@ -1082,6 +1088,7 @@ class Cloud(object): continue vm_ = profile_details.copy() + vm_.update(vm_opts) vm_['name'] = name if self.opts['parallel']: process = multiprocessing.Process( diff --git a/salt/modules/cloud.py b/salt/modules/cloud.py index ba9a0fc6e4..05de9604a9 100644 --- a/salt/modules/cloud.py +++ b/salt/modules/cloud.py @@ -130,7 +130,7 @@ def select_query(query_type='list_nodes_select'): return query(query_type='list_nodes_select') -def profile_(profile, names, **kwargs): +def profile_(profile, names, vm_opts=None, **kwargs): ''' Spin up an instance using Salt Cloud @@ -141,7 +141,7 @@ def profile_(profile, names, **kwargs): salt '*' cloud.profile my-gce-config myinstance ''' client = _get_client() - info = client.profile(profile, names, **kwargs) + info = client.profile(profile, names, vm_opts=vm_opts, **kwargs) return info diff --git a/salt/states/cloud.py b/salt/states/cloud.py index f56b7dc731..3f2b0712f7 100644 --- a/salt/states/cloud.py +++ b/salt/states/cloud.py @@ -234,7 +234,7 @@ def profile(name, profile, onlyif=None, unless=None, **kwargs): if __opts__['test']: ret['comment'] = 'Instance {0} needs to be created'.format(name) return ret - info = __salt__['cloud.profile'](profile, name, **kwargs) + info = __salt__['cloud.profile'](profile, name, vm_opts=kwargs) if info and not 'Error' in info: ret['changes'] = info ret['result'] = True