0

Hope you are all well!

I'm automating the deployment of a MongoDB replica set in AWS EC2 through the Salt-Stack Salt-Cloud python API.

I'd like to use a single script to provision the servers:

client=salt.cloud.CloutClient(path'/etc/salt/cloud')
client.profile('db_node_profile',names=['host1','host2','host3'])

However, I'd like the 1st server to be created using a different cloud profile, say db_master_profile. There is a vm_overrides option for the 'profile' client (see documentation linked above), but I can't find further detail on how it should work.

Can anyone shed some light on how vm_overrides works, if this is a possible solution, or an alternative manner to provision the instances based on Salt-Cloud profiles using a low-overhead SINGLE script?

Mr.Budris
  • 552
  • 5
  • 21

1 Answers1

0

The vm_overrides option is used to change the configurations of the minions in the moment of provisioning. It can override any of the configs set in the profile but it can't modify the profile which you are using.

For you scenario you could do two things:

  1. Change all the configurations you would like with the vm_overrides. It would not be practical as you already have a specific profile.

Example:

client=salt.cloud.CloutClient(path'/etc/salt/cloud')
client.profile('db_node_profile',names=['host1','host2','host3'])
{
  'host1': {'backups_active': 'False',
    'created_at': '2014-09-04T18:10:15Z',
    'droplet': {'event_id': 31000502,
                'id': 2530006,
                'image_id': 5140006,
                'name': u'minion01',
                'size_id': 66},
    'id': '2530006',
    'image_id': '5140006',
    'ip_address': '107.XXX.XXX.XXX',
    'locked': 'True',
    'name': 'minion01',
    'private_ip_address': None,
    'region_id': '4',
    'size_id': '66',
    'status': 'new'}
}
  1. You could call client.profile twice in your script, once for the first server with the different profile and another one for the remaining servers with the default profile.

Example:

client=salt.cloud.CloutClient(path'/etc/salt/cloud')
client.profile('db_node_profile_0',names=['host1'])
client.profile('db_node_profile_1',names=['host2','host3'])
alejdg
  • 2,313
  • 21
  • 28
  • Actually, the 2nd example does not work as-is; it's something I've tried in the past. It seems like each command gets passed from python to salt quite quickly, and the second one is 'lost' before the first one completes. If you try it it does not actually provision the second machine. Might need to incorporate a ping test of some variety. – Mr.Budris Dec 29 '16 at 22:03