Merge pull request #1410 from resmo/fix/stable-2.0/cs_instance
[stable-2.0] cloudstack: cs_instance: fix do not require name to be set to avoid c…
This commit is contained in:
commit
8f6d518a5b
1 changed files with 18 additions and 5 deletions
|
@ -30,10 +30,15 @@ options:
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- Host name of the instance. C(name) can only contain ASCII letters.
|
- Host name of the instance. C(name) can only contain ASCII letters.
|
||||||
required: true
|
- Name will be generated (UUID) by CloudStack if not specified and can not be changed afterwards.
|
||||||
|
- Either C(name) or C(display_name) is required.
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
display_name:
|
display_name:
|
||||||
description:
|
description:
|
||||||
- Custom display name of the instances.
|
- Custom display name of the instances.
|
||||||
|
- Display name will be set to C(name) if not specified.
|
||||||
|
- Either C(name) or C(display_name) is required.
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
group:
|
group:
|
||||||
|
@ -225,16 +230,21 @@ EXAMPLES = '''
|
||||||
service_offering: 2cpu_2gb
|
service_offering: 2cpu_2gb
|
||||||
force: yes
|
force: yes
|
||||||
|
|
||||||
# Create or update a instance on Exoscale's public cloud
|
# Create or update a instance on Exoscale's public cloud using display_name.
|
||||||
|
# Note: user_data can be used to kickstart the instance using cloud-init yaml config.
|
||||||
- local_action:
|
- local_action:
|
||||||
module: cs_instance
|
module: cs_instance
|
||||||
name: web-vm-1
|
display_name: web-vm-1
|
||||||
template: Linux Debian 7 64-bit
|
template: Linux Debian 7 64-bit
|
||||||
service_offering: Tiny
|
service_offering: Tiny
|
||||||
ssh_key: john@example.com
|
ssh_key: john@example.com
|
||||||
tags:
|
tags:
|
||||||
- { key: admin, value: john }
|
- { key: admin, value: john }
|
||||||
- { key: foo, value: bar }
|
- { key: foo, value: bar }
|
||||||
|
user_data: |
|
||||||
|
#cloud-config
|
||||||
|
packages:
|
||||||
|
- nginx
|
||||||
|
|
||||||
# Create an instance with multiple interfaces specifying the IP addresses
|
# Create an instance with multiple interfaces specifying the IP addresses
|
||||||
- local_action:
|
- local_action:
|
||||||
|
@ -479,7 +489,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
||||||
def get_instance(self):
|
def get_instance(self):
|
||||||
instance = self.instance
|
instance = self.instance
|
||||||
if not instance:
|
if not instance:
|
||||||
instance_name = self.module.params.get('name')
|
instance_name = self.get_or_fallback('name', 'display_name')
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
args['account'] = self.get_account(key='name')
|
args['account'] = self.get_account(key='name')
|
||||||
|
@ -865,7 +875,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
||||||
def main():
|
def main():
|
||||||
argument_spec = cs_argument_spec()
|
argument_spec = cs_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
name = dict(required=True),
|
name = dict(default=None),
|
||||||
display_name = dict(default=None),
|
display_name = dict(default=None),
|
||||||
group = dict(default=None),
|
group = dict(default=None),
|
||||||
state = dict(choices=['present', 'deployed', 'started', 'stopped', 'restarted', 'restored', 'absent', 'destroyed', 'expunged'], default='present'),
|
state = dict(choices=['present', 'deployed', 'started', 'stopped', 'restarted', 'restored', 'absent', 'destroyed', 'expunged'], default='present'),
|
||||||
|
@ -905,6 +915,9 @@ def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=argument_spec,
|
argument_spec=argument_spec,
|
||||||
required_together=required_together,
|
required_together=required_together,
|
||||||
|
required_one_of = (
|
||||||
|
['display_name', 'name'],
|
||||||
|
),
|
||||||
mutually_exclusive = (
|
mutually_exclusive = (
|
||||||
['template', 'iso'],
|
['template', 'iso'],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue