diff --git a/lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py b/lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py index d07cb048c4..2f2e3841ff 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py @@ -19,22 +19,26 @@ module: cs_instance_facts short_description: Gathering facts from the API of instances from Apache CloudStack based clouds. description: - Gathering facts from the API of an instance. -version_added: "2.1" -author: "René Moser (@resmo)" +version_added: '2.1' +author: René Moser (@resmo) options: name: description: - Name or display name of the instance. + type: str required: true domain: description: - Domain the instance is related to. + type: str account: description: - Account the instance is related to. + type: str project: description: - Project the instance is related to. + type: str extends_documentation_fragment: cloudstack ''' @@ -157,7 +161,7 @@ affinity_groups: tags: description: List of resource tags associated with the instance. returned: success - type: dict + type: list sample: '[ { "key": "foo", "value": "bar" } ]' hypervisor: description: Hypervisor related to this instance. diff --git a/lib/ansible/modules/cloud/cloudstack/cs_network.py b/lib/ansible/modules/cloud/cloudstack/cs_network.py index cbb335ffb0..ee616daad4 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_network.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_network.py @@ -98,10 +98,11 @@ options: type: bool acl_type: description: - - Access control type for the VPC network tier. + - Access control type for the network. + - If not specified, Cloudstack will default to C(account) for isolated networks + - and C(domain) for shared networks. - Only considered on create. type: str - default: account choices: [ account, domain ] acl: description: @@ -269,7 +270,7 @@ tags: type: list sample: '[ { "key": "foo", "value": "bar" } ]' acl_type: - description: Access type of the VPC network tier (Domain, Account). + description: Access type of the network (Domain, Account). returned: success type: str sample: Account diff --git a/lib/ansible/modules/cloud/cloudstack/cs_network_offering.py b/lib/ansible/modules/cloud/cloudstack/cs_network_offering.py index 422f3b4252..73e8a149c4 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_network_offering.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_network_offering.py @@ -16,37 +16,44 @@ short_description: Manages network offerings on Apache CloudStack based clouds. description: - Create, update, enable, disable and remove network offerings. version_added: '2.5' -author: "David Passante (@dpassante)" +author: David Passante (@dpassante) options: state: description: - State of the network offering. + type: str choices: [ enabled, present, disabled, absent] default: present display_text: description: - Display text of the network offerings. + type: str guest_ip_type: description: - Guest type of the network offering. + type: str choices: [ Shared, Isolated ] name: description: - The name of the network offering. + type: str required: true supported_services: description: - Services supported by the network offering. - - One or more of the choices. + - A list of one or more items from the choice list. + type: list choices: [ Dns, PortForwarding, Dhcp, SourceNat, UserData, Firewall, StaticNat, Vpn, Lb ] aliases: [ supported_service ] traffic_type: description: - The traffic type for the network offering. + type: str default: Guest availability: description: - The availability of network offering. Default value is Optional + type: str conserve_mode: description: - Whether the network offering has IP conserve mode enabled. @@ -55,10 +62,11 @@ options: description: - Network offering details in key/value pairs. - with service provider as a value - choices: [ internallbprovider, publiclbprovider ] + type: list egress_default_policy: description: - Whether the default egress policy is allow or to deny. + type: str choices: [ allow, deny ] persistent: description: @@ -74,21 +82,26 @@ options: max_connections: description: - Maximum number of concurrent connections supported by the network offering. + type: int network_rate: description: - Data transfer rate in megabits per second allowed. + type: int service_capabilities: description: - Desired service capabilities as part of network offering. + type: list aliases: [ service_capability ] service_offering: description: - The service offering name or ID used by virtual router provider. - service_provider: + type: str + service_providers: description: - Provider to service mapping. - If not specified, the provider for the service will be mapped to the default provider on the physical network. - aliases: [service_provider] + type: list + aliases: [ service_provider ] specify_ip_ranges: description: - Wheter the network offering supports specifying IP ranges. @@ -103,8 +116,7 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' - name: Create a network offering and enable it - local_action: - module: cs_network_offering + cs_network_offering: name: my_network_offering display_text: network offering description state: enabled @@ -113,13 +125,14 @@ EXAMPLES = ''' service_providers: - { service: 'dns', provider: 'virtualrouter' } - { service: 'dhcp', provider: 'virtualrouter' } + delegate_to: localhost - name: Remove a network offering - local_action: - module: cs_network_offering + cs_network_offering: name: my_network_offering state: absent + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_pod.py b/lib/ansible/modules/cloud/cloudstack/cs_pod.py index 9ca87cb27c..5b53368435 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_pod.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_pod.py @@ -16,73 +16,81 @@ module: cs_pod short_description: Manages pods on Apache CloudStack based clouds. description: - Create, update, delete pods. -version_added: "2.1" -author: "René Moser (@resmo)" +version_added: '2.1' +author: René Moser (@resmo) options: name: description: - Name of the pod. + type: str required: true id: description: - uuid of the existing pod. + type: str start_ip: description: - Starting IP address for the Pod. - - Required on C(state=present) + - Required on I(state=present) + type: str end_ip: description: - Ending IP address for the Pod. + type: str netmask: description: - Netmask for the Pod. - - Required on C(state=present) + - Required on I(state=present) + type: str gateway: description: - Gateway for the Pod. - - Required on C(state=present) + - Required on I(state=present) + type: str zone: description: - Name of the zone in which the pod belongs to. - If not set, default zone is used. + type: str state: description: - State of the pod. - default: 'present' - choices: [ 'present', 'enabled', 'disabled', 'absent' ] + type: str + default: present + choices: [ present, enabled, disabled, absent ] extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' - name: Ensure a pod is present - local_action: - module: cs_pod + cs_pod: name: pod1 zone: ch-zrh-ix-01 start_ip: 10.100.10.101 gateway: 10.100.10.1 netmask: 255.255.255.0 + delegate_to: localhost - name: Ensure a pod is disabled - local_action: - module: cs_pod + cs_pod: name: pod1 zone: ch-zrh-ix-01 state: disabled + delegate_to: localhost - name: Ensure a pod is enabled - local_action: - module: cs_pod + cs_pod: name: pod1 zone: ch-zrh-ix-01 state: enabled + delegate_to: localhost - name: Ensure a pod is absent - local_action: - module: cs_pod + cs_pod: name: pod1 zone: ch-zrh-ix-01 state: absent + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_portforward.py b/lib/ansible/modules/cloud/cloudstack/cs_portforward.py index 48b484f9b7..a735b050e9 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_portforward.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_portforward.py @@ -20,121 +20,136 @@ short_description: Manages port forwarding rules on Apache CloudStack based clou description: - Create, update and remove port forwarding rules. version_added: '2.0' -author: "René Moser (@resmo)" +author: René Moser (@resmo) options: ip_address: description: - Public IP address the rule is assigned to. + type: str required: true vm: description: - Name of virtual machine which we make the port forwarding rule for. - - Required if C(state=present). + - Required if I(state=present). + type: str state: description: - State of the port forwarding rule. + type: str default: present choices: [ present, absent ] protocol: description: - Protocol of the port forwarding rule. + type: str default: tcp choices: [ tcp, udp ] public_port: description: - Start public port for this rule. + type: int required: true public_end_port: description: - End public port for this rule. - - If not specified equal C(public_port). + - If not specified equal I(public_port). + type: int private_port: description: - Start private port for this rule. + type: int required: true private_end_port: description: - End private port for this rule. - - If not specified equal C(private_port). + - If not specified equal I(private_port). + type: int open_firewall: description: - Whether the firewall rule for public port should be created, while creating the new rule. - Use M(cs_firewall) for managing firewall rules. - default: false + default: no type: bool vm_guest_ip: description: - VM guest NIC secondary IP address for the port forwarding rule. - default: false + type: str network: description: - Name of the network. - version_added: "2.3" + type: str + version_added: '2.3' vpc: description: - Name of the VPC. - version_added: "2.3" + version_added: '2.3' + type: str domain: description: - - Domain the C(vm) is related to. + - Domain the I(vm) is related to. + type: str account: description: - - Account the C(vm) is related to. + - Account the I(vm) is related to. + type: str project: description: - - Name of the project the C(vm) is located in. + - Name of the project the I(vm) is located in. + type: str zone: description: - Name of the zone in which the virtual machine is in. - If not set, default zone is used. + type: str poll_async: description: - Poll async jobs until job has finished. - default: true + default: yes type: bool tags: description: - - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). - - "To delete all tags, set a empty list e.g. C(tags: [])." + - List of tags. Tags are a list of dictionaries having keys I(key) and I(value). + - "To delete all tags, set a empty list e.g. I(tags: [])." + type: list aliases: [ tag ] - version_added: "2.4" + version_added: '2.4' extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' - name: 1.2.3.4:80 -> web01:8080 - local_action: - module: cs_portforward + cs_portforward: ip_address: 1.2.3.4 vm: web01 public_port: 80 private_port: 8080 + delegate_to: localhost - name: forward SSH and open firewall - local_action: - module: cs_portforward + cs_portforward: ip_address: '{{ public_ip }}' vm: '{{ inventory_hostname }}' public_port: '{{ ansible_ssh_port }}' private_port: 22 open_firewall: true + delegate_to: localhost - name: forward DNS traffic, but do not open firewall - local_action: - module: cs_portforward + cs_portforward: ip_address: 1.2.3.4 vm: '{{ inventory_hostname }}' public_port: 53 private_port: 53 protocol: udp + delegate_to: localhost - name: remove ssh port forwarding - local_action: - module: cs_portforward + cs_portforward: ip_address: 1.2.3.4 public_port: 22 private_port: 22 state: absent + delegate_to: localhost ''' RETURN = ''' @@ -163,6 +178,7 @@ private_end_port: description: End port on the virtual machine's IP address. returned: success type: int + sample: 80 public_port: description: Start port on the public IP address. returned: success diff --git a/lib/ansible/modules/cloud/cloudstack/cs_project.py b/lib/ansible/modules/cloud/cloudstack/cs_project.py index f059c1a565..3647eb3229 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_project.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_project.py @@ -2,21 +2,7 @@ # -*- coding: utf-8 -*- # # (c) 2015, René Moser -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], @@ -30,72 +16,79 @@ short_description: Manages projects on Apache CloudStack based clouds. description: - Create, update, suspend, activate and remove projects. version_added: '2.0' -author: "René Moser (@resmo)" +author: René Moser (@resmo) options: name: description: - Name of the project. + type: str required: true display_text: description: - Display text of the project. - - If not specified, C(name) will be used as C(display_text). + - If not specified, I(name) will be used as I(display_text). + type: str state: description: - State of the project. - default: 'present' - choices: [ 'present', 'absent', 'active', 'suspended' ] + type: str + default: present + choices: [ present, absent, active, suspended ] domain: description: - Domain the project is related to. + type: str account: description: - Account the project is related to. + type: str tags: description: - - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). - - "If you want to delete all tags, set a empty list e.g. C(tags: [])." - version_added: "2.2" + - List of tags. Tags are a list of dictionaries having keys I(key) and I(value). + - "If you want to delete all tags, set a empty list e.g. I(tags: [])." + type: list + aliases: [ tag ] + version_added: '2.2' poll_async: description: - Poll async jobs until job has finished. type: bool - default: 'yes' + default: yes extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# Create a project -- local_action: - module: cs_project +- name: Create a project + cs_project: name: web tags: - { key: admin, value: john } - { key: foo, value: bar } + delegate_to: localhost -# Rename a project -- local_action: - module: cs_project +- name: Rename a project + cs_project: name: web display_text: my web project + delegate_to: localhost -# Suspend an existing project -- local_action: - module: cs_project +- name: Suspend an existing project + cs_project: name: web state: suspended + delegate_to: localhost -# Activate an existing project -- local_action: - module: cs_project +- name: Activate an existing project + cs_project: name: web state: active + delegate_to: localhost -# Remove a project -- local_action: - module: cs_project +- name: Remove a project + cs_project: name: web state: absent + delegate_to: localhost ''' RETURN = ''' @@ -133,7 +126,7 @@ account: tags: description: List of resource tags associated with the project. returned: success - type: dict + type: list sample: '[ { "key": "foo", "value": "bar" } ]' ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_region.py b/lib/ansible/modules/cloud/cloudstack/cs_region.py index c8db4bc380..065d89f930 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_region.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_region.py @@ -2,21 +2,7 @@ # -*- coding: utf-8 -*- # # (c) 2016, René Moser -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], @@ -29,43 +15,47 @@ module: cs_region short_description: Manages regions on Apache CloudStack based clouds. description: - Add, update and remove regions. -version_added: "2.3" -author: "René Moser (@resmo)" +version_added: '2.3' +author: René Moser (@resmo) options: id: description: - ID of the region. - Must be an number (int). + type: int required: true name: description: - Name of the region. - - Required if C(state=present) + - Required if I(state=present) + type: str endpoint: description: - Endpoint URL of the region. - - Required if C(state=present) + - Required if I(state=present) + type: str state: description: - State of the region. - default: 'present' - choices: [ 'present', 'absent' ] + type: str + default: present + choices: [ present, absent ] extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# create a region -- local_action: - module: cs_region +- name: create a region + cs_region: id: 2 name: geneva endpoint: https://cloud.gva.example.com + delegate_to: localhost -# remove a region with ID 2 -- local_action: - module: cs_region +- name: remove a region with ID 2 + cs_region: id: 2 state: absent + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_resourcelimit.py b/lib/ansible/modules/cloud/cloudstack/cs_resourcelimit.py index 1792af80b9..509dcc30c5 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_resourcelimit.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_resourcelimit.py @@ -15,12 +15,13 @@ module: cs_resourcelimit short_description: Manages resource limits on Apache CloudStack based clouds. description: - Manage limits of resources for domains, accounts and projects. -version_added: "2.1" -author: "René Moser (@resmo)" +version_added: '2.1' +author: René Moser (@resmo) options: resource_type: description: - Type of the resource. + type: str required: true choices: - instance @@ -34,40 +35,44 @@ options: - memory - primary_storage - secondary_storage - aliases: [ 'type' ] + aliases: [ type ] limit: description: - Maximum number of the resource. - Default is unlimited C(-1). + type: int default: -1 - aliases: [ 'max' ] + aliases: [ max ] domain: description: - Domain the resource is related to. + type: str account: description: - Account the resource is related to. + type: str project: description: - Name of the project the resource is related to. + type: str extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' - name: Update a resource limit for instances of a domain - local_action: - module: cs_resourcelimit + cs_resourcelimit: type: instance limit: 10 domain: customers + delegate_to: localhost - name: Update a resource limit for instances of an account - local_action: - module: cs_resourcelimit + cs_resourcelimit: type: instance limit: 12 account: moserre domain: customers + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_role.py b/lib/ansible/modules/cloud/cloudstack/cs_role.py index 8d4e33ead3..001cdf924f 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_role.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_role.py @@ -2,21 +2,7 @@ # -*- coding: utf-8 -*- # # (c) 2016, René Moser -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], @@ -29,52 +15,57 @@ module: cs_role short_description: Manages user roles on Apache CloudStack based clouds. description: - Create, update, delete user roles. -version_added: "2.3" -author: "René Moser (@resmo)" +version_added: '2.3' +author: René Moser (@resmo) options: name: description: - Name of the role. + type: str required: true id: description: - ID of the role. - - If provided, C(id) is used as key. - aliases: [ 'uuid' ] + - If provided, I(id) is used as key. + type: str + aliases: [ uuid ] role_type: description: - Type of the role. - Only considered for creation. + type: str default: User - choices: [ 'User', 'DomainAdmin', 'ResourceAdmin', 'Admin' ] + choices: [ User, DomainAdmin, ResourceAdmin, Admin ] description: description: - Description of the role. + type: str state: description: - State of the role. - default: 'present' - choices: [ 'present', 'absent' ] + type: str + default: present + choices: [ present, absent ] extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# Ensure an user role is present -- local_action: - module: cs_role +- name: Ensure an user role is present + cs_role: name: myrole_user + delegate_to: localhost -# Ensure a role having particular ID is named as myrole_user -- local_action: - module: cs_role +- name: Ensure a role having particular ID is named as myrole_user + cs_role: name: myrole_user id: 04589590-ac63-4ffc-93f5-b698b8ac38b6 + delegate_to: localhost -# Ensure a role is absent -- local_action: - module: cs_role +- name: Ensure a role is absent + cs_role: name: myrole_user state: absent + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_role_permission.py b/lib/ansible/modules/cloud/cloudstack/cs_role_permission.py index 6862ecfc7c..16cbb3442c 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_role_permission.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_role_permission.py @@ -16,64 +16,70 @@ description: - Create, update and remove CloudStack role permissions. - Managing role permissions only supported in CloudStack >= 4.9. version_added: '2.6' -author: "David Passante (@dpassante)" +author: David Passante (@dpassante) options: name: description: - The API name of the permission. + type: str required: true role: description: - Name or ID of the role. + type: str required: true permission: description: - The rule permission, allow or deny. Defaulted to deny. + type: str choices: [ allow, deny ] default: deny state: description: - State of the role permission. + type: str choices: [ present, absent ] default: present description: description: - The description of the role permission. + type: str parent: description: - The parent role permission uuid. use 0 to move this rule at the top of the list. + type: str extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# Create a role permission -- local_action: - module: cs_role_permission - role: "My_Custom_role" - name: "createVPC" - permission: "allow" - description: "My comments" +- name: Create a role permission + cs_role_permission: + role: My_Custom_role + name: createVPC + permission: allow + description: My comments + delegate_to: localhost -# Remove a role permission -- local_action: - module: cs_role_permission +- name: Remove a role permission + cs_role_permission: state: absent - role: "My_Custom_role" - name: "createVPC" + role: My_Custom_role + name: createVPC + delegate_to: localhost -# Update a system role permission -- local_action: - module: cs_role_permission - role: "Domain Admin" - name: "createVPC" - permission: "deny" +- name: Update a system role permission + cs_role_permission: + role: Domain Admin + name: createVPC + permission: deny + delegate_to: localhost -# Update rules order. Move the rule at the top of list -- local_action: - module: cs_role_permission - role: "Domain Admin" - name: "createVPC" +- name: Update rules order. Move the rule at the top of list + cs_role_permission: + role: Domain Admin + name: createVPC parent: 0 + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_router.py b/lib/ansible/modules/cloud/cloudstack/cs_router.py index fd7bf79d91..496d28e562 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_router.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_router.py @@ -2,21 +2,7 @@ # -*- coding: utf-8 -*- # # (c) 2016, René Moser -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], @@ -29,36 +15,43 @@ module: cs_router short_description: Manages routers on Apache CloudStack based clouds. description: - Start, restart, stop and destroy routers. - - C(state=present) is not able to create routers, use M(cs_network) instead. -version_added: "2.2" -author: "René Moser (@resmo)" + - I(state=present) is not able to create routers, use M(cs_network) instead. +version_added: '2.2' +author: René Moser (@resmo) options: name: description: - Name of the router. + type: str required: true service_offering: description: - Name or id of the service offering of the router. + type: str domain: description: - Domain the router is related to. + type: str account: description: - Account the router is related to. + type: str project: description: - Name of the project the router is related to. + type: str zone: description: - Name of the zone the router is deployed in. - If not set, all zones are used. - version_added: "2.4" + type: str + version_added: '2.4' state: description: - State of the router. - default: 'present' - choices: [ 'present', 'absent', 'started', 'stopped', 'restarted' ] + type: str + default: present + choices: [ present, absent, started, stopped, restarted ] poll_async: description: - Poll async jobs until job has finished. @@ -70,36 +63,38 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' # Ensure the router has the desired service offering, no matter if # the router is running or not. -- local_action: - module: cs_router +- name: Present router + cs_router: name: r-40-VM service_offering: System Offering for Software Router + delegate_to: localhost -# Ensure started -- local_action: - module: cs_router +- name: Ensure started + cs_router: name: r-40-VM state: started + delegate_to: localhost # Ensure started with desired service offering. # If the service offerings changes, router will be rebooted. -- local_action: - module: cs_router +- name: Ensure started with desired service offering + cs_router: name: r-40-VM service_offering: System Offering for Software Router state: started + delegate_to: localhost -# Ensure stopped -- local_action: - module: cs_router +- name: Ensure stopped + cs_router: name: r-40-VM state: stopped + delegate_to: localhost -# Remove a router -- local_action: - module: cs_router +- name: Remove a router + cs_router: name: r-40-VM state: absent + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_securitygroup.py b/lib/ansible/modules/cloud/cloudstack/cs_securitygroup.py index a6625a172e..9567516aa0 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_securitygroup.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_securitygroup.py @@ -20,44 +20,50 @@ short_description: Manages security groups on Apache CloudStack based clouds. description: - Create and remove security groups. version_added: '2.0' -author: "René Moser (@resmo)" +author: René Moser (@resmo) options: name: description: - Name of the security group. + type: str required: true description: description: - Description of the security group. + type: str state: description: - State of the security group. + type: str default: present choices: [ present, absent ] domain: description: - Domain the security group is related to. + type: str account: description: - Account the security group is related to. + type: str project: description: - Name of the project the security group to be created in. + type: str extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' - name: create a security group - local_action: - module: cs_securitygroup + cs_securitygroup: name: default description: default security group + delegate_to: localhost - name: remove a security group - local_action: - module: cs_securitygroup + cs_securitygroup: name: default state: absent + delegate_to: localhost ''' RETURN = ''' @@ -80,7 +86,7 @@ description: tags: description: List of resource tags associated with the security group. returned: success - type: dict + type: list sample: '[ { "key": "foo", "value": "bar" } ]' project: description: Name of project the security group is related to. diff --git a/lib/ansible/modules/cloud/cloudstack/cs_securitygroup_rule.py b/lib/ansible/modules/cloud/cloudstack/cs_securitygroup_rule.py index 7599408c87..27ee88d433 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_securitygroup_rule.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_securitygroup_rule.py @@ -20,54 +20,65 @@ short_description: Manages security group rules on Apache CloudStack based cloud description: - Add and remove security group rules. version_added: '2.0' -author: "René Moser (@resmo)" +author: René Moser (@resmo) options: security_group: description: - Name of the security group the rule is related to. The security group must be existing. + type: str required: true state: description: - State of the security group rule. + type: str default: present choices: [ present, absent ] protocol: description: - Protocol of the security group rule. + type: str default: tcp choices: [ tcp, udp, icmp, ah, esp, gre ] type: description: - Ingress or egress security group rule. + type: str default: ingress choices: [ ingress, egress ] cidr: description: - CIDR (full notation) to be used for security group rule. - default: '0.0.0.0/0' + type: str + default: 0.0.0.0/0 user_security_group: description: - Security group this rule is based of. + type: str start_port: description: - - Start port for this rule. Required if C(protocol=tcp) or C(protocol=udp). + - Start port for this rule. Required if I(protocol=tcp) or I(protocol=udp). + type: int aliases: [ port ] end_port: description: - - End port for this rule. Required if C(protocol=tcp) or C(protocol=udp), but C(start_port) will be used if not set. + - End port for this rule. Required if I(protocol=tcp) or I(protocol=udp), but I(start_port) will be used if not set. + type: int icmp_type: description: - - Type of the icmp message being sent. Required if C(protocol=icmp). + - Type of the icmp message being sent. Required if I(protocol=icmp). + type: int icmp_code: description: - - Error code for this icmp message. Required if C(protocol=icmp). + - Error code for this icmp message. Required if I(protocol=icmp). + type: int project: description: - Name of the project the security group to be created in. + type: str poll_async: description: - Poll async jobs until job has finished. - default: true + default: yes type: bool extends_documentation_fragment: cloudstack ''' @@ -75,15 +86,14 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' --- - name: allow inbound port 80/tcp from 1.2.3.4 added to security group 'default' - local_action: - module: cs_securitygroup_rule + cs_securitygroup_rule: security_group: default port: 80 cidr: 1.2.3.4/32 + delegate_to: localhost - name: allow tcp/udp outbound added to security group 'default' - local_action: - module: cs_securitygroup_rule + cs_securitygroup_rule: security_group: default type: egress start_port: 1 @@ -92,28 +102,29 @@ EXAMPLES = ''' with_items: - tcp - udp + delegate_to: localhost - name: allow inbound icmp from 0.0.0.0/0 added to security group 'default' - local_action: - module: cs_securitygroup_rule + cs_securitygroup_rule: security_group: default protocol: icmp icmp_code: -1 icmp_type: -1 + delegate_to: localhost - name: remove rule inbound port 80/tcp from 0.0.0.0/0 from security group 'default' - local_action: - module: cs_securitygroup_rule + cs_securitygroup_rule: security_group: default port: 80 state: absent + delegate_to: localhost - name: allow inbound port 80/tcp from security group web added to security group 'default' - local_action: - module: cs_securitygroup_rule + cs_securitygroup_rule: security_group: default port: 80 user_security_group: web + delegate_to: localhost ''' RETURN = ''' diff --git a/test/sanity/validate-modules/ignore.txt b/test/sanity/validate-modules/ignore.txt index cd4476a461..94b384b534 100644 --- a/test/sanity/validate-modules/ignore.txt +++ b/test/sanity/validate-modules/ignore.txt @@ -98,11 +98,6 @@ lib/ansible/modules/cloud/centurylink/clc_firewall_policy.py E335 lib/ansible/modules/cloud/centurylink/clc_server_snapshot.py E335 lib/ansible/modules/cloud/cloudstack/cs_cluster.py E326 lib/ansible/modules/cloud/cloudstack/cs_host.py E326 -lib/ansible/modules/cloud/cloudstack/cs_network.py E324 -lib/ansible/modules/cloud/cloudstack/cs_network_offering.py E322 -lib/ansible/modules/cloud/cloudstack/cs_network_offering.py E326 -lib/ansible/modules/cloud/cloudstack/cs_portforward.py E324 -lib/ansible/modules/cloud/cloudstack/cs_project.py E322 lib/ansible/modules/cloud/cloudstack/cs_service_offering.py E322 lib/ansible/modules/cloud/cloudstack/cs_service_offering.py E323 lib/ansible/modules/cloud/cloudstack/cs_service_offering.py E326