mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adding string support to metadata argument
This patch adds support to setting metadata key/value through a string argument. Variables can now be used for both the metadata key and value. example: meta: "{{ var1 }}:SomeValue,key:{{ var2 }}"
This commit is contained in:
parent
d98683e1c5
commit
11f66c0742
1 changed files with 28 additions and 1 deletions
|
@ -113,7 +113,8 @@ options:
|
||||||
meta:
|
meta:
|
||||||
description:
|
description:
|
||||||
- A list of key value pairs that should be provided as a metadata to
|
- A list of key value pairs that should be provided as a metadata to
|
||||||
the new instance.
|
the new instance or a string containing a list of key-value pairs.
|
||||||
|
Eg: meta: "key1=value1,key2=value2"
|
||||||
required: false
|
required: false
|
||||||
default: None
|
default: None
|
||||||
wait:
|
wait:
|
||||||
|
@ -263,6 +264,25 @@ EXAMPLES = '''
|
||||||
timeout: 200
|
timeout: 200
|
||||||
flavor: 4
|
flavor: 4
|
||||||
nics: "net-id=4cb08b20-62fe-11e5-9d70-feff819cdc9f,net-id=542f0430-62fe-11e5-9d70-feff819cdc9f..."
|
nics: "net-id=4cb08b20-62fe-11e5-9d70-feff819cdc9f,net-id=542f0430-62fe-11e5-9d70-feff819cdc9f..."
|
||||||
|
|
||||||
|
# Creates a new instance and attaches to a network and passes metadata to
|
||||||
|
# the instance
|
||||||
|
- os_server:
|
||||||
|
state: present
|
||||||
|
auth:
|
||||||
|
auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
|
||||||
|
username: admin
|
||||||
|
password: admin
|
||||||
|
project_name: admin
|
||||||
|
name: vm1
|
||||||
|
image: 4f905f38-e52a-43d2-b6ec-754a13ffb529
|
||||||
|
key_name: ansible_key
|
||||||
|
timeout: 200
|
||||||
|
flavor: 4
|
||||||
|
nics:
|
||||||
|
- net-id: 34605f38-e52a-25d2-b6ec-754a13ffb723
|
||||||
|
- net-name: another_network
|
||||||
|
meta: "hostname=test1,group=uge_master"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,6 +355,13 @@ def _create_server(module, cloud):
|
||||||
|
|
||||||
nics = _network_args(module, cloud)
|
nics = _network_args(module, cloud)
|
||||||
|
|
||||||
|
if type(module.params['meta']) is str:
|
||||||
|
metas = {}
|
||||||
|
for kv_str in module.params['meta'].split(","):
|
||||||
|
k, v = kv_str.split("=")
|
||||||
|
metas[k] = v
|
||||||
|
module.params['meta'] = metas
|
||||||
|
|
||||||
bootkwargs = dict(
|
bootkwargs = dict(
|
||||||
name=module.params['name'],
|
name=module.params['name'],
|
||||||
image=image_id,
|
image=image_id,
|
||||||
|
|
Loading…
Add table
Reference in a new issue