Add support for tagging newly created DigitalOcean droplets.

This commit is contained in:
Ken Koch 2017-10-01 07:32:33 -04:00
parent 63821381a0
commit 06eb9c30dd
2 changed files with 10 additions and 1 deletions

View File

@ -54,6 +54,7 @@ Set up an initial profile at ``/etc/salt/cloud.profiles`` or in the
ipv6: True
create_dns_record: True
userdata_file: /etc/salt/cloud.userdata.d/setup
tags:tag1,tag2,tag3
Locations can be obtained using the ``--list-locations`` option for the ``salt-cloud``
command:

View File

@ -298,7 +298,8 @@ def create(vm_):
'size': get_size(vm_),
'image': get_image(vm_),
'region': get_location(vm_),
'ssh_keys': []
'ssh_keys': [],
'tags': []
}
# backwards compat
@ -379,6 +380,13 @@ def create(vm_):
raise SaltCloudConfigError("'ipv6' should be a boolean value.")
kwargs['ipv6'] = ipv6
tag_string = config.get_cloud_config_value(
'tags', vm_, __opts__, search_global=False, default=False
)
if tag_string:
for tag in tag_string.split(','):
kwargs['tags'].append(tag)
userdata_file = config.get_cloud_config_value(
'userdata_file', vm_, __opts__, search_global=False, default=None
)