Merge pull request #560 from resmo/for-ansible

cloudstack updates, merged as owner_pr. Thanks @resmo!
reviewable/pr18780/r1
Greg DeKoenigsberg 10 years ago
commit 9439555881

@ -108,7 +108,6 @@ local_action:
email: john.doe@example.com email: john.doe@example.com
domain: CUSTOMERS domain: CUSTOMERS
# Lock an existing account in domain 'CUSTOMERS' # Lock an existing account in domain 'CUSTOMERS'
local_action: local_action:
module: cs_account module: cs_account
@ -116,7 +115,6 @@ local_action:
domain: CUSTOMERS domain: CUSTOMERS
state: locked state: locked
# Disable an existing account in domain 'CUSTOMERS' # Disable an existing account in domain 'CUSTOMERS'
local_action: local_action:
module: cs_account module: cs_account
@ -124,7 +122,6 @@ local_action:
domain: CUSTOMERS domain: CUSTOMERS
state: disabled state: disabled
# Enable an existing account in domain 'CUSTOMERS' # Enable an existing account in domain 'CUSTOMERS'
local_action: local_action:
module: cs_account module: cs_account
@ -132,7 +129,6 @@ local_action:
domain: CUSTOMERS domain: CUSTOMERS
state: enabled state: enabled
# Remove an account in domain 'CUSTOMERS' # Remove an account in domain 'CUSTOMERS'
local_action: local_action:
module: cs_account module: cs_account
@ -367,7 +363,11 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

@ -72,7 +72,6 @@ EXAMPLES = '''
name: haproxy name: haproxy
affinty_type: host anti-affinity affinty_type: host anti-affinity
# Remove a affinity group # Remove a affinity group
- local_action: - local_action:
module: cs_affinitygroup module: cs_affinitygroup
@ -221,7 +220,11 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

@ -115,7 +115,6 @@ EXAMPLES = '''
port: 80 port: 80
cidr: 1.2.3.4/32 cidr: 1.2.3.4/32
# Allow inbound tcp/udp port 53 to 4.3.2.1 # Allow inbound tcp/udp port 53 to 4.3.2.1
- local_action: - local_action:
module: cs_firewall module: cs_firewall
@ -126,7 +125,6 @@ EXAMPLES = '''
- tcp - tcp
- udp - udp
# Ensure firewall rule is removed # Ensure firewall rule is removed
- local_action: - local_action:
module: cs_firewall module: cs_firewall
@ -136,7 +134,6 @@ EXAMPLES = '''
cidr: 17.0.0.0/8 cidr: 17.0.0.0/8
state: absent state: absent
# Allow all outbound traffic # Allow all outbound traffic
- local_action: - local_action:
module: cs_firewall module: cs_firewall
@ -144,7 +141,6 @@ EXAMPLES = '''
type: egress type: egress
protocol: all protocol: all
# Allow only HTTP outbound traffic for an IP # Allow only HTTP outbound traffic for an IP
- local_action: - local_action:
module: cs_firewall module: cs_firewall
@ -420,7 +416,15 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_one_of = (
['ip_address', 'network'],
),
required_together = (
['icmp_type', 'icmp_code'],
['api_key', 'api_secret', 'api_url'],
), ),
mutually_exclusive = ( mutually_exclusive = (
['icmp_type', 'start_port'], ['icmp_type', 'start_port'],

@ -23,7 +23,7 @@ DOCUMENTATION = '''
module: cs_instance module: cs_instance
short_description: Manages instances and virtual machines on Apache CloudStack based clouds. short_description: Manages instances and virtual machines on Apache CloudStack based clouds.
description: description:
- Deploy, start, restart, stop and destroy instances on Apache CloudStack, Citrix CloudPlatform and Exoscale. - Deploy, start, restart, stop and destroy instances.
version_added: '2.0' version_added: '2.0'
author: '"René Moser (@resmo)" <mail@renemoser.net>' author: '"René Moser (@resmo)" <mail@renemoser.net>'
options: options:
@ -49,22 +49,29 @@ options:
choices: [ 'deployed', 'started', 'stopped', 'restarted', 'destroyed', 'expunged', 'present', 'absent' ] choices: [ 'deployed', 'started', 'stopped', 'restarted', 'destroyed', 'expunged', 'present', 'absent' ]
service_offering: service_offering:
description: description:
- Name or id of the service offering of the new instance. If not set, first found service offering is used. - Name or id of the service offering of the new instance.
- If not set, first found service offering is used.
required: false required: false
default: null default: null
template: template:
description: description:
- Name or id of the template to be used for creating the new instance. Required when using C(state=present). Mutually exclusive with C(ISO) option. - Name or id of the template to be used for creating the new instance.
- Required when using C(state=present).
- Mutually exclusive with C(ISO) option.
required: false required: false
default: null default: null
iso: iso:
description: description:
- Name or id of the ISO to be used for creating the new instance. Required when using C(state=present). Mutually exclusive with C(template) option. - Name or id of the ISO to be used for creating the new instance.
- Required when using C(state=present).
- Mutually exclusive with C(template) option.
required: false required: false
default: null default: null
hypervisor: hypervisor:
description: description:
- Name the hypervisor to be used for creating the new instance. Relevant when using C(state=present) and option C(ISO) is used. If not set, first found hypervisor will be used. - Name the hypervisor to be used for creating the new instance.
- Relevant when using C(state=present) and option C(ISO) is used.
- If not set, first found hypervisor will be used.
required: false required: false
default: null default: null
choices: [ 'KVM', 'VMware', 'BareMetal', 'XenServer', 'LXC', 'HyperV', 'UCS', 'OVM' ] choices: [ 'KVM', 'VMware', 'BareMetal', 'XenServer', 'LXC', 'HyperV', 'UCS', 'OVM' ]
@ -82,7 +89,7 @@ options:
aliases: [ 'network' ] aliases: [ 'network' ]
ip_address: ip_address:
description: description:
- IPv4 address for default instance's network during creation - IPv4 address for default instance's network during creation.
required: false required: false
default: null default: null
ip6_address: ip6_address:
@ -123,7 +130,8 @@ options:
default: null default: null
zone: zone:
description: description:
- Name of the zone in which the instance shoud be deployed. If not set, default zone is used. - Name of the zone in which the instance shoud be deployed.
- If not set, default zone is used.
required: false required: false
default: null default: null
ssh_key: ssh_key:
@ -148,7 +156,7 @@ options:
description: description:
- Force stop/start the instance if required to apply changes, otherwise a running instance will not be changed. - Force stop/start the instance if required to apply changes, otherwise a running instance will not be changed.
required: false required: false
default: true default: false
tags: tags:
description: description:
- List of tags. Tags are a list of dictionaries having keys C(key) and C(value). - List of tags. Tags are a list of dictionaries having keys C(key) and C(value).
@ -164,7 +172,7 @@ extends_documentation_fragment: cloudstack
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Create a instance on CloudStack from an ISO # Create a instance from an ISO
# NOTE: Names of offerings and ISOs depending on the CloudStack configuration. # NOTE: Names of offerings and ISOs depending on the CloudStack configuration.
- local_action: - local_action:
module: cs_instance module: cs_instance
@ -181,7 +189,6 @@ EXAMPLES = '''
- Sync Integration - Sync Integration
- Storage Integration - Storage Integration
# For changing a running instance, use the 'force' parameter # For changing a running instance, use the 'force' parameter
- local_action: - local_action:
module: cs_instance module: cs_instance
@ -191,7 +198,6 @@ 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
- local_action: - local_action:
module: cs_instance module: cs_instance
@ -202,19 +208,13 @@ EXAMPLES = '''
tags: tags:
- { key: admin, value: john } - { key: admin, value: john }
- { key: foo, value: bar } - { key: foo, value: bar }
register: vm
- debug: msg='default ip {{ vm.default_ip }} and is in state {{ vm.state }}'
# Ensure a instance has stopped # Ensure a instance has stopped
- local_action: cs_instance name=web-vm-1 state=stopped - local_action: cs_instance name=web-vm-1 state=stopped
# Ensure a instance is running # Ensure a instance is running
- local_action: cs_instance name=web-vm-1 state=started - local_action: cs_instance name=web-vm-1 state=started
# Remove a instance # Remove a instance
- local_action: cs_instance name=web-vm-1 state=absent - local_action: cs_instance name=web-vm-1 state=absent
''' '''
@ -257,7 +257,7 @@ password:
type: string type: string
sample: Ge2oe7Do sample: Ge2oe7Do
ssh_key: ssh_key:
description: Name of ssh key deployed to instance. description: Name of SSH key deployed to instance.
returned: success returned: success
type: string type: string
sample: key@work sample: key@work
@ -282,7 +282,7 @@ default_ip:
type: string type: string
sample: 10.23.37.42 sample: 10.23.37.42
public_ip: public_ip:
description: Public IP address with instance via static nat rule. description: Public IP address with instance via static NAT rule.
returned: success returned: success
type: string type: string
sample: 1.2.3.4 sample: 1.2.3.4
@ -326,6 +326,16 @@ tags:
returned: success returned: success
type: dict type: dict
sample: '[ { "key": "foo", "value": "bar" } ]' sample: '[ { "key": "foo", "value": "bar" } ]'
hypervisor:
description: Hypervisor related to this instance.
returned: success
type: string
sample: KVM
instance_name:
description: Internal name of the instance (ROOT admin only).
returned: success
type: string
sample: i-44-3992-VM
''' '''
import base64 import base64
@ -712,6 +722,10 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
self.result['account'] = instance['account'] self.result['account'] = instance['account']
if 'project' in instance: if 'project' in instance:
self.result['project'] = instance['project'] self.result['project'] = instance['project']
if 'hypervisor' in instance:
self.result['hypervisor'] = instance['hypervisor']
if 'instancename' in instance:
self.result['instance_name'] = instance['instancename']
if 'publicip' in instance: if 'publicip' in instance:
self.result['public_ip'] = instance['public_ip'] self.result['public_ip'] = instance['public_ip']
if 'passwordenabled' in instance: if 'passwordenabled' in instance:
@ -771,7 +785,7 @@ def main():
disk_offering = dict(default=None), disk_offering = dict(default=None),
disk_size = dict(type='int', default=None), disk_size = dict(type='int', default=None),
keyboard = dict(choices=['de', 'de-ch', 'es', 'fi', 'fr', 'fr-be', 'fr-ch', 'is', 'it', 'jp', 'nl-be', 'no', 'pt', 'uk', 'us'], default=None), keyboard = dict(choices=['de', 'de-ch', 'es', 'fi', 'fr', 'fr-be', 'fr-ch', 'is', 'it', 'jp', 'nl-be', 'no', 'pt', 'uk', 'us'], default=None),
hypervisor = dict(default=None), hypervisor = dict(choices=['KVM', 'VMware', 'BareMetal', 'XenServer', 'LXC', 'HyperV', 'UCS', 'OVM'], default=None),
security_groups = dict(type='list', aliases=[ 'security_group' ], default=[]), security_groups = dict(type='list', aliases=[ 'security_group' ], default=[]),
affinity_groups = dict(type='list', aliases=[ 'affinity_group' ], default=[]), affinity_groups = dict(type='list', aliases=[ 'affinity_group' ], default=[]),
domain = dict(default=None), domain = dict(default=None),
@ -786,7 +800,11 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

@ -61,7 +61,6 @@ EXAMPLES = '''
module: cs_instancegroup module: cs_instancegroup
name: loadbalancers name: loadbalancers
# Remove an instance group # Remove an instance group
- local_action: - local_action:
module: cs_instancegroup module: cs_instancegroup
@ -198,7 +197,11 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

@ -116,23 +116,20 @@ EXAMPLES = '''
url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso
os_type: Debian GNU/Linux 7(64-bit) os_type: Debian GNU/Linux 7(64-bit)
# Register an ISO with given name if ISO md5 checksum does not already exist. # Register an ISO with given name if ISO md5 checksum does not already exist.
- local_action: - local_action:
module: cs_iso module: cs_iso
name: Debian 7 64-bit name: Debian 7 64-bit
url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso
os_type: os_type: Debian GNU/Linux 7(64-bit)
checksum: 0b31bccccb048d20b551f70830bb7ad0 checksum: 0b31bccccb048d20b551f70830bb7ad0
# Remove an ISO by name # Remove an ISO by name
- local_action: - local_action:
module: cs_iso module: cs_iso
name: Debian 7 64-bit name: Debian 7 64-bit
state: absent state: absent
# Remove an ISO by checksum # Remove an ISO by checksum
- local_action: - local_action:
module: cs_iso module: cs_iso
@ -331,7 +328,11 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

@ -92,12 +92,13 @@ options:
default: null default: null
project: project:
description: description:
- Name of the project the c(vm) is located in. - Name of the project the C(vm) is located in.
required: false required: false
default: null default: null
zone: zone:
description: description:
- Name of the zone in which the virtual machine is in. If not set, default zone is used. - Name of the zone in which the virtual machine is in.
- If not set, default zone is used.
required: false required: false
default: null default: null
poll_async: poll_async:
@ -117,7 +118,6 @@ EXAMPLES = '''
public_port: 80 public_port: 80
private_port: 8080 private_port: 8080
# forward SSH and open firewall # forward SSH and open firewall
- local_action: - local_action:
module: cs_portforward module: cs_portforward
@ -127,7 +127,6 @@ EXAMPLES = '''
private_port: 22 private_port: 22
open_firewall: true open_firewall: true
# forward DNS traffic, but do not open firewall # forward DNS traffic, but do not open firewall
- local_action: - local_action:
module: cs_portforward module: cs_portforward
@ -138,7 +137,6 @@ EXAMPLES = '''
protocol: udp protocol: udp
open_firewall: true open_firewall: true
# remove ssh port forwarding # remove ssh port forwarding
- local_action: - local_action:
module: cs_portforward module: cs_portforward
@ -161,21 +159,21 @@ protocol:
type: string type: string
sample: tcp sample: tcp
private_port: private_port:
description: Private start port. description: Start port on the virtual machine's IP address.
returned: success returned: success
type: int type: int
sample: 80 sample: 80
private_end_port: private_end_port:
description: Private end port. description: End port on the virtual machine's IP address.
returned: success returned: success
type: int type: int
public_port: public_port:
description: Public start port. description: Start port on the public IP address.
returned: success returned: success
type: int type: int
sample: 80 sample: 80
public_end_port: public_end_port:
description: Public end port. description: End port on the public IP address.
returned: success returned: success
type: int type: int
sample: 80 sample: 80
@ -201,7 +199,6 @@ vm_guest_ip:
sample: 10.101.65.152 sample: 10.101.65.152
''' '''
try: try:
from cs import CloudStack, CloudStackException, read_config from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True has_lib_cs = True
@ -405,7 +402,11 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

@ -57,7 +57,6 @@ EXAMPLES = '''
name: default name: default
description: default security group description: default security group
# Remove a security group # Remove a security group
- local_action: - local_action:
module: cs_securitygroup module: cs_securitygroup
@ -165,7 +164,11 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

@ -102,7 +102,6 @@ EXAMPLES = '''
port: 80 port: 80
cidr: 1.2.3.4/32 cidr: 1.2.3.4/32
# Allow tcp/udp outbound added to security group 'default' # Allow tcp/udp outbound added to security group 'default'
- local_action: - local_action:
module: cs_securitygroup_rule module: cs_securitygroup_rule
@ -115,7 +114,6 @@ EXAMPLES = '''
- tcp - tcp
- udp - udp
# Allow inbound icmp from 0.0.0.0/0 added to security group 'default' # Allow inbound icmp from 0.0.0.0/0 added to security group 'default'
- local_action: - local_action:
module: cs_securitygroup_rule module: cs_securitygroup_rule
@ -124,7 +122,6 @@ EXAMPLES = '''
icmp_code: -1 icmp_code: -1
icmp_type: -1 icmp_type: -1
# Remove rule inbound port 80/tcp from 0.0.0.0/0 from security group 'default' # Remove rule inbound port 80/tcp from 0.0.0.0/0 from security group 'default'
- local_action: - local_action:
module: cs_securitygroup_rule module: cs_securitygroup_rule
@ -132,7 +129,6 @@ EXAMPLES = '''
port: 80 port: 80
state: absent state: absent
# Allow inbound port 80/tcp from security group web added to security group 'default' # Allow inbound port 80/tcp from security group web added to security group 'default'
- local_action: - local_action:
module: cs_securitygroup_rule module: cs_securitygroup_rule
@ -400,7 +396,12 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['icmp_type', 'icmp_code'],
['api_key', 'api_secret', 'api_url'],
), ),
mutually_exclusive = ( mutually_exclusive = (
['icmp_type', 'start_port'], ['icmp_type', 'start_port'],

@ -217,7 +217,11 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

@ -88,7 +88,6 @@ EXAMPLES = '''
vm: web-01 vm: web-01
snapshot_memory: yes snapshot_memory: yes
# Revert a VM to a snapshot after a failed upgrade # Revert a VM to a snapshot after a failed upgrade
- local_action: - local_action:
module: cs_vmsnapshot module: cs_vmsnapshot
@ -96,7 +95,6 @@ EXAMPLES = '''
vm: web-01 vm: web-01
state: revert state: revert
# Remove a VM snapshot after successful upgrade # Remove a VM snapshot after successful upgrade
- local_action: - local_action:
module: cs_vmsnapshot module: cs_vmsnapshot
@ -290,7 +288,12 @@ def main():
api_key = dict(default=None), api_key = dict(default=None),
api_secret = dict(default=None, no_log=True), api_secret = dict(default=None, no_log=True),
api_url = dict(default=None), api_url = dict(default=None),
api_http_method = dict(default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
),
required_together = (
['icmp_type', 'icmp_code'],
['api_key', 'api_secret', 'api_url'],
), ),
supports_check_mode=True supports_check_mode=True
) )

Loading…
Cancel
Save