diff --git a/lib/ansible/modules/cloud/cloudstack/cs_instancegroup.py b/lib/ansible/modules/cloud/cloudstack/cs_instancegroup.py index e74fb18f08..83663143fc 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_instancegroup.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_instancegroup.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,40 +16,45 @@ short_description: Manages instance groups on Apache CloudStack based clouds. description: - Create and remove instance groups. version_added: '2.0' -author: "René Moser (@resmo)" +author: René Moser (@resmo) options: name: description: - Name of the instance group. + type: str required: true domain: description: - Domain the instance group is related to. + type: str account: description: - Account the instance group is related to. + type: str project: description: - Project the instance group is related to. + type: str state: description: - State of the instance group. - default: 'present' - choices: [ 'present', 'absent' ] + type: str + default: present + choices: [ present, absent ] extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# Create an instance group -- local_action: - module: cs_instancegroup +- name: Create an instance group + cs_instancegroup: name: loadbalancers + delegate_to: localhost -# Remove an instance group -- local_action: - module: cs_instancegroup +- name: Remove an instance group + cs_instancegroup: name: loadbalancers state: absent + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_ip_address.py b/lib/ansible/modules/cloud/cloudstack/cs_ip_address.py index 14706a99bf..d0a27f8dd2 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_ip_address.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_ip_address.py @@ -17,42 +17,50 @@ short_description: Manages public IP address associations on Apache CloudStack b description: - Acquires and associates a public IP to an account or project. - Due to API limitations this is not an idempotent call, so be sure to only - conditionally call this when C(state=present). + conditionally call this when I(state=present). - Tagging the IP address can also make the call idempotent. version_added: '2.0' author: - - "Darren Worrall (@dazworrall)" - - "René Moser (@resmo)" + - Darren Worrall (@dazworrall) + - René Moser (@resmo) options: ip_address: description: - Public IP address. - Required if I(state=absent) and I(tags) is not set. + type: str domain: description: - Domain the IP address is related to. + type: str network: description: - Network the IP address is related to. - Mutually exclusive with I(vpc). + type: str vpc: description: - VPC the IP address is related to. - Mutually exclusive with I(network). - version_added: "2.2" + type: str + version_added: '2.2' account: description: - Account the IP address is related to. + type: str project: description: - Name of the project the IP address is related to. + type: str zone: description: - Name of the zone in which the IP address is in. - If not set, default zone is used. + type: str state: description: - State of the IP address. + type: str default: present choices: [ present, absent ] tags: @@ -60,46 +68,47 @@ options: - List of tags. Tags are a list of dictionaries having keys I(key) and I(value). - Tags can be used as an unique identifier for the IP Addresses. - In this case, at least one of them must be unique to ensure idempontency. - aliases: [ 'tag' ] - version_added: "2.6" + type: list + aliases: [ tag ] + version_added: '2.6' poll_async: description: - Poll async jobs until job has finished. type: bool - default: 'yes' + default: yes extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' - name: Associate an IP address conditonally - local_action: - module: cs_ip_address + cs_ip_address: network: My Network register: ip_address when: instance.public_ip is undefined + delegate_to: localhost - name: Disassociate an IP address - local_action: - module: cs_ip_address + cs_ip_address: ip_address: 1.2.3.4 state: absent + delegate_to: localhost - name: Associate an IP address with tags - local_action: - module: cs_ip_address + cs_ip_address: network: My Network tags: - key: myCustomID - value: 5510c31a-416e-11e8-9013-02000a6b00bf register: ip_address + delegate_to: localhost - name: Disassociate an IP address with tags - local_action: - module: cs_ip_address + cs_ip_address: state: absent tags: - key: myCustomID - value: 5510c31a-416e-11e8-9013-02000a6b00bf + delegate_to: localhost ''' RETURN = ''' @@ -139,7 +148,7 @@ tags: returned: success type: dict sample: '[ { "key": "myCustomID", "value": "5510c31a-416e-11e8-9013-02000a6b00bf" } ]' - version_added: "2.6" + version_added: '2.6' ''' from ansible.module_utils.basic import AnsibleModule diff --git a/lib/ansible/modules/cloud/cloudstack/cs_iso.py b/lib/ansible/modules/cloud/cloudstack/cs_iso.py index 430dec2ad0..cede97274f 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_iso.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_iso.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,23 +16,27 @@ short_description: Manages ISO images on Apache CloudStack based clouds. description: - Register and remove ISO images. version_added: '2.0' -author: "René Moser (@resmo)" +author: René Moser (@resmo) options: name: description: - Name of the ISO. + type: str required: true display_text: description: - Display text of the ISO. - - If not specified, C(name) will be used. - version_added: "2.4" + - If not specified, I(name) will be used. + type: str + version_added: '2.4' url: description: - - URL where the ISO can be downloaded from. Required if C(state) is present. + - URL where the ISO can be downloaded from. Required if I(state) is present. + type: str os_type: description: - - Name of the OS that best represents the OS of this ISO. If the iso is bootable this parameter needs to be passed. Required if C(state) is present. + - Name of the OS that best represents the OS of this ISO. If the iso is bootable this parameter needs to be passed. Required if I(state) is present. + type: str is_ready: description: - This flag is used for searching existing ISOs. If set to C(yes), it will only list ISO ready for deployment e.g. @@ -55,95 +45,104 @@ options: default: no is_public: description: - - Register the ISO to be publicly available to all users. Only used if C(state) is present. + - Register the ISO to be publicly available to all users. Only used if I(state) is present. + type: bool is_featured: description: - - Register the ISO to be featured. Only used if C(state) is present. + - Register the ISO to be featured. Only used if I(state) is present. type: bool is_dynamically_scalable: description: - - Register the ISO having XS/VMWare tools installed inorder to support dynamic scaling of VM cpu/memory. Only used if C(state) is present. + - Register the ISO having XS/VMWare tools installed inorder to support dynamic scaling of VM cpu/memory. Only used if I(state) is present. type: bool checksum: description: - The MD5 checksum value of this ISO. If set, we search by checksum instead of name. + type: str bootable: description: - - Register the ISO to be bootable. Only used if C(state) is present. + - Register the ISO to be bootable. Only used if I(state) is present. type: bool domain: description: - Domain the ISO is related to. + type: str account: description: - Account the ISO is related to. + type: str project: description: - Name of the project the ISO to be registered in. + type: str zone: description: - Name of the zone you wish the ISO to be registered or deleted from. - If not specified, first zone found will be used. + type: str cross_zones: description: - Whether the ISO should be synced or removed across zones. - - Mutually exclusive with C(zone). + - Mutually exclusive with I(zone). type: bool - default: 'no' - version_added: "2.4" + default: no + version_added: '2.4' iso_filter: description: - Name of the filter used to search for the ISO. - default: 'self' - choices: [ 'featured', 'self', 'selfexecutable','sharedexecutable','executable', 'community' ] + type: str + default: self + choices: [ featured, self, selfexecutable,sharedexecutable,executable, community ] state: description: - State of the ISO. - default: 'present' - choices: [ 'present', 'absent' ] + type: str + default: present + choices: [ present, absent ] poll_async: description: - Poll async jobs until job has finished. type: bool - default: 'yes' - version_added: "2.3" + default: yes + version_added: '2.3' 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: [])." - aliases: [ 'tag' ] - version_added: "2.4" + - 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' extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# Register an ISO if ISO name does not already exist. -- local_action: - module: cs_iso +- name: Register an ISO if ISO name does not already exist + cs_iso: 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 os_type: Debian GNU/Linux 7(64-bit) + delegate_to: localhost -# Register an ISO with given name if ISO md5 checksum does not already exist. -- local_action: - module: cs_iso +- name: Register an ISO with given name if ISO md5 checksum does not already exist + cs_iso: 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 os_type: Debian GNU/Linux 7(64-bit) checksum: 0b31bccccb048d20b551f70830bb7ad0 + delegate_to: localhost -# Remove an ISO by name -- local_action: - module: cs_iso +- name: Remove an ISO by name + cs_iso: name: Debian 7 64-bit state: absent + delegate_to: localhost -# Remove an ISO by checksum -- local_action: - module: cs_iso +- name: Remove an ISO by checksum + cs_iso: name: Debian 7 64-bit checksum: 0b31bccccb048d20b551f70830bb7ad0 state: absent + delegate_to: localhost ''' RETURN = ''' @@ -183,31 +182,31 @@ is_public: returned: success type: bool sample: true - version_added: "2.4" + version_added: '2.4' bootable: description: True if the ISO is bootable. returned: success type: bool sample: true - version_added: "2.4" + version_added: '2.4' is_featured: description: True if the ISO is featured. returned: success type: bool sample: true - version_added: "2.4" + version_added: '2.4' format: description: Format of the ISO. returned: success type: str sample: ISO - version_added: "2.4" + version_added: '2.4' os_type: description: Typo of the OS. returned: success type: str sample: CentOS 6.5 (64-bit) - version_added: "2.4" + version_added: '2.4' checksum: description: MD5 checksum of the ISO. returned: success @@ -223,7 +222,7 @@ cross_zones: returned: success type: bool sample: false - version_added: "2.4" + version_added: '2.4' domain: description: Domain the ISO is related to. returned: success @@ -244,7 +243,7 @@ tags: returned: success type: dict sample: '[ { "key": "foo", "value": "bar" } ]' - version_added: "2.4" + version_added: '2.4' ''' from ansible.module_utils.basic import AnsibleModule diff --git a/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule.py b/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule.py index 3e3a36ce96..3b52ff283e 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule.py @@ -3,21 +3,7 @@ # # (c) 2015, Darren Worrall # (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'], @@ -32,96 +18,120 @@ description: - Add, update and remove load balancer rules. version_added: '2.0' author: - - "Darren Worrall (@dazworrall)" - - "René Moser (@resmo)" + - Darren Worrall (@dazworrall) + - René Moser (@resmo) options: name: description: - The name of the load balancer rule. + type: str required: true description: description: - The description of the load balancer rule. + type: str algorithm: description: - Load balancer algorithm - - Required when using C(state=present). - choices: [ 'source', 'roundrobin', 'leastconn' ] - default: 'source' + - Required when using I(state=present). + type: str + choices: [ source, roundrobin, leastconn ] + default: source private_port: description: - The private port of the private ip address/virtual machine where the network traffic will be load balanced to. - - Required when using C(state=present). + - Required when using I(state=present). - Can not be changed once the rule exists due API limitation. + type: int public_port: description: - The public port from where the network traffic will be load balanced from. - - Required when using C(state=present). + - Required when using I(state=present). - Can not be changed once the rule exists due API limitation. + type: int required: true ip_address: description: - Public IP address from where the network traffic will be load balanced from. + type: str required: true - aliases: [ 'public_ip' ] + aliases: [ public_ip ] 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. type: bool - default: 'no' + default: no cidr: description: - CIDR (full notation) to be used for firewall rule if required. + type: str protocol: description: - The protocol to be used on the load balancer + type: str project: description: - Name of the project the load balancer IP address is related to. + type: str state: description: - State of the rule. - default: 'present' - choices: [ 'present', 'absent' ] + type: str + default: present + choices: [ present, absent ] domain: description: - Domain the rule is related to. + type: str account: description: - Account the rule is related to. + type: str zone: description: - Name of the zone in which the rule should be created. - If not set, default zone is used. + type: str + poll_async: + description: + - Poll async jobs until job has finished. + type: bool + default: yes + tags: + description: + - 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 ] extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# Create a load balancer rule -- local_action: - module: cs_loadbalancer_rule +- name: Create a load balancer rule + cs_loadbalancer_rule: name: balance_http public_ip: 1.2.3.4 algorithm: leastconn public_port: 80 private_port: 8080 + delegate_to: localhost -# update algorithm of an existing load balancer rule -- local_action: - module: cs_loadbalancer_rule +- name: Update algorithm of an existing load balancer rule + cs_loadbalancer_rule: name: balance_http public_ip: 1.2.3.4 algorithm: roundrobin public_port: 80 private_port: 8080 + delegate_to: localhost -# Delete a load balancer rule -- local_action: - module: cs_loadbalancer_rule +- name: Delete a load balancer rule + cs_loadbalancer_rule: name: balance_http public_ip: 1.2.3.4 state: absent + delegate_to: localhost ''' RETURN = ''' @@ -155,52 +165,52 @@ algorithm: description: Load balancer algorithm used. returned: success type: str - sample: "source" + sample: source cidr: description: CIDR to forward traffic from. returned: success type: str - sample: "" + sample: 0.0.0.0/0 name: description: Name of the rule. returned: success type: str - sample: "http-lb" + sample: http-lb description: description: Description of the rule. returned: success type: str - sample: "http load balancer rule" + sample: http load balancer rule protocol: description: Protocol of the rule. returned: success type: str - sample: "tcp" + sample: tcp public_port: description: Public port. returned: success - type: str + type: int sample: 80 private_port: description: Private IP address. returned: success - type: str + type: int sample: 80 public_ip: description: Public IP address. returned: success type: str - sample: "1.2.3.4" + sample: 1.2.3.4 tags: description: List of resource tags associated with the rule. returned: success - type: dict + type: list sample: '[ { "key": "foo", "value": "bar" } ]' state: description: State of the rule. returned: success type: str - sample: "Add" + sample: Add ''' from ansible.module_utils.basic import AnsibleModule diff --git a/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py b/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py index 02b72763eb..a680a532b0 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py @@ -18,41 +18,49 @@ description: - Add and remove load balancer rule members. version_added: '2.0' author: - - "Darren Worrall (@dazworrall)" - - "René Moser (@resmo)" + - Darren Worrall (@dazworrall) + - René Moser (@resmo) options: name: description: - The name of the load balancer rule. + type: str required: true ip_address: description: - Public IP address from where the network traffic will be load balanced from. - - Only needed to find the rule if C(name) is not unique. - aliases: [ 'public_ip' ] + - Only needed to find the rule if I(name) is not unique. + type: str + aliases: [ public_ip ] vms: description: - List of VMs to assign to or remove from the rule. + type: list required: true - aliases: [ 'vm' ] + aliases: [ vm ] state: description: - Should the VMs be present or absent from the rule. - default: 'present' - choices: [ 'present', 'absent' ] + type: str + default: present + choices: [ present, absent ] project: description: - Name of the project the firewall rule is related to. + type: str domain: description: - Domain the rule is related to. + type: str account: description: - Account the rule is related to. + type: str zone: description: - Name of the zone in which the rule should be located. - If not set, default zone is used. + type: str poll_async: description: - Poll async jobs until job has finished. @@ -63,41 +71,41 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' - name: Add VMs to an existing load balancer - local_action: - module: cs_loadbalancer_rule_member + cs_loadbalancer_rule_member: name: balance_http vms: - web01 - web02 + delegate_to: localhost - name: Remove a VM from an existing load balancer - local_action: - module: cs_loadbalancer_rule_member + cs_loadbalancer_rule_member: name: balance_http vms: - web01 - web02 state: absent + delegate_to: localhost # Rolling upgrade of hosts - hosts: webservers serial: 1 pre_tasks: - name: Remove from load balancer - local_action: - module: cs_loadbalancer_rule_member + cs_loadbalancer_rule_member: name: balance_http vm: "{{ ansible_hostname }}" state: absent + delegate_to: localhost tasks: # Perform update post_tasks: - name: Add to load balancer - local_action: - module: cs_loadbalancer_rule_member + cs_loadbalancer_rule_member: name: balance_http vm: "{{ ansible_hostname }}" state: present + delegate_to: localhost ''' RETURN = ''' @@ -131,42 +139,42 @@ algorithm: description: Load balancer algorithm used. returned: success type: str - sample: "source" + sample: source cidr: description: CIDR to forward traffic from. returned: success type: str - sample: "" + sample: 0.0.0.0/0 name: description: Name of the rule. returned: success type: str - sample: "http-lb" + sample: http-lb description: description: Description of the rule. returned: success type: str - sample: "http load balancer rule" + sample: http load balancer rule protocol: description: Protocol of the rule. returned: success type: str - sample: "tcp" + sample: tcp public_port: description: Public port. returned: success - type: str + type: int sample: 80 private_port: description: Private IP address. returned: success - type: str + type: int sample: 80 public_ip: description: Public IP address. returned: success type: str - sample: "1.2.3.4" + sample: 1.2.3.4 vms: description: Rule members. returned: success @@ -175,13 +183,13 @@ vms: tags: description: List of resource tags associated with the rule. returned: success - type: dict + type: list sample: '[ { "key": "foo", "value": "bar" } ]' state: description: State of the rule. returned: success type: str - sample: "Add" + sample: Add ''' from ansible.module_utils.basic import AnsibleModule diff --git a/lib/ansible/modules/cloud/cloudstack/cs_network.py b/lib/ansible/modules/cloud/cloudstack/cs_network.py index 9de87fd668..cbb335ffb0 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_network.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_network.py @@ -17,52 +17,62 @@ short_description: Manages networks on Apache CloudStack based clouds. description: - Create, update, restart and delete networks. version_added: '2.0' -author: "René Moser (@resmo)" +author: René Moser (@resmo) options: name: description: - Name (case sensitive) of the network. + type: str required: true display_text: description: - Display text of the network. - - 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 network_offering: description: - Name of the offering for the network. - - Required if C(state=present). + - Required if I(state=present). + type: str start_ip: description: - The beginning IPv4 address of the network belongs to. - Only considered on create. + type: str end_ip: description: - The ending IPv4 address of the network belongs to. - - If not specified, value of C(start_ip) is used. + - If not specified, value of I(start_ip) is used. - Only considered on create. + type: str gateway: description: - The gateway of the network. - Required for shared networks and isolated networks when it belongs to a VPC. - Only considered on create. + type: str netmask: description: - The netmask of the network. - Required for shared networks and isolated networks when it belongs to a VPC. - Only considered on create. + type: str start_ipv6: description: - The beginning IPv6 address of the network belongs to. - Only considered on create. + type: str end_ipv6: description: - The ending IPv6 address of the network belongs to. - - If not specified, value of C(start_ipv6) is used. + - If not specified, value of I(start_ipv6) is used. - Only considered on create. + type: str cidr_ipv6: description: - CIDR of IPv6 network, must be at least /64. - Only considered on create. + type: str gateway_ipv6: description: - The gateway of the IPv6 network. @@ -71,56 +81,67 @@ options: vlan: description: - The ID or VID of the network. + type: str vpc: description: - Name of the VPC of the network. + type: str isolated_pvlan: description: - The isolated private VLAN for this network. + type: str clean_up: description: - Cleanup old network elements. - - Only considered on C(state=restarted). + - Only considered on I(state=restarted). default: no type: bool acl_type: description: - Access control type for the VPC network tier. - Only considered on create. + type: str default: account choices: [ account, domain ] acl: description: - The name of the access control list for the VPC network tier. - version_added: "2.5" + type: str + version_added: '2.5' subdomain_access: description: - Defines whether to allow subdomains to use networks dedicated to their parent domain(s). - - Should be used with C(acl_type=domain). + - Should be used with I(acl_type=domain). - Only considered on create. type: bool - version_added: "2.5" + version_added: '2.5' network_domain: description: - The network domain. + type: str state: description: - State of the network. + type: str default: present choices: [ present, absent, restarted ] zone: description: - Name of the zone in which the network should be deployed. - If not set, default zone is used. + type: str project: description: - Name of the project the network to be deployed in. + type: str domain: description: - Domain the network is related to. + type: str account: description: - Account the network is related to. + type: str poll_async: description: - Poll async jobs until job has finished. @@ -131,16 +152,15 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' - name: Create a network - local_action: - module: cs_network + cs_network: name: my network zone: gva-01 network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService network_domain: example.com + delegate_to: localhost - name: Create a VPC tier - local_action: - module: cs_network + cs_network: name: my VPC tier 1 zone: gva-01 vpc: my VPC @@ -148,26 +168,27 @@ EXAMPLES = ''' gateway: 10.43.0.1 netmask: 255.255.255.0 acl: my web acl + delegate_to: localhost - name: Update a network - local_action: - module: cs_network + cs_network: name: my network display_text: network of domain example.local network_domain: example.local + delegate_to: localhost - name: Restart a network with clean up - local_action: - module: cs_network + cs_network: name: my network clean_up: yes state: restared + delegate_to: localhost - name: Remove a network - local_action: - module: cs_network + cs_network: name: my network state: absent + delegate_to: localhost ''' RETURN = ''' @@ -214,12 +235,12 @@ netmask: sample: 255.255.255.0 cidr_ipv6: description: IPv6 network CIDR. - returned: success + returned: if available type: str sample: 2001:db8::/64 gateway_ipv6: description: IPv6 gateway. - returned: success + returned: if available type: str sample: 2001:db8::1 zone: @@ -245,7 +266,7 @@ project: tags: description: List of resource tags associated with the network. returned: success - type: dict + type: list sample: '[ { "key": "foo", "value": "bar" } ]' acl_type: description: Access type of the VPC network tier (Domain, Account). @@ -257,13 +278,13 @@ acl: returned: success type: str sample: My ACL - version_added: "2.5" + version_added: '2.5' acl_id: description: ID of the access control list for the VPC network tier. returned: success type: str sample: dfafcd55-0510-4b8c-b6c5-b8cedb4cfd88 - version_added: "2.5" + version_added: '2.5' broadcast_domain_type: description: Broadcast domain type of the network. returned: success @@ -304,25 +325,30 @@ network_offering_display_text: returned: success type: str sample: Offering for Isolated Vpc networks with Source Nat service enabled - version_added: "2.5" + version_added: '2.5' network_offering_conserve_mode: description: Whether the network offering has IP conserve mode enabled or not. returned: success type: bool sample: false - version_added: "2.5" + version_added: '2.5' network_offering_availability: description: The availability of the network offering the network is created from returned: success type: str sample: Optional - version_added: "2.5" + version_added: '2.5' is_system: description: Whether the network is system related or not. returned: success type: bool sample: false - version_added: "2.5" + version_added: '2.5' +vpc: + description: Name of the VPC. + returned: if available + type: str + sample: My VPC ''' from ansible.module_utils.basic import AnsibleModule diff --git a/lib/ansible/modules/cloud/cloudstack/cs_network_acl.py b/lib/ansible/modules/cloud/cloudstack/cs_network_acl.py index 52ac9d0c9f..a38102fb56 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_network_acl.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_network_acl.py @@ -2,21 +2,7 @@ # -*- coding: utf-8 -*- # # (c) 2017, 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'], @@ -28,61 +14,69 @@ module: cs_network_acl short_description: Manages network access control lists (ACL) on Apache CloudStack based clouds. description: - Create and remove network ACLs. -version_added: "2.4" -author: "René Moser (@resmo)" +version_added: '2.4' +author: René Moser (@resmo) options: name: description: - Name of the network ACL. + type: str required: true description: description: - Description of the network ACL. - - If not set, identical to C(name). + - If not set, identical to I(name). + type: str vpc: description: - VPC the network ACL is related to. + type: str required: true state: description: - State of the network ACL. - default: 'present' - choices: [ 'present', 'absent' ] + type: str + default: present + choices: [ present, absent ] domain: description: - Domain the network ACL rule is related to. + type: str account: description: - Account the network ACL rule is related to. + type: str project: description: - Name of the project the network ACL is related to. + type: str zone: description: - Name of the zone the VPC is related to. - If not set, default zone is used. + type: str poll_async: description: - Poll async jobs until job has finished. type: bool - default: 'yes' + default: yes extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# create a network ACL -- local_action: - module: cs_network_acl +- name: create a network ACL + cs_network_acl: name: Webserver ACL description: a more detailed description of the ACL vpc: customers + delegate_to: localhost -# remove a network ACL -- local_action: - module: cs_network_acl +- name: remove a network ACL + cs_network_acl: name: Webserver ACL vpc: customers state: absent + delegate_to: localhost ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_network_acl_rule.py b/lib/ansible/modules/cloud/cloudstack/cs_network_acl_rule.py index 693580e9d2..2a1e3e2e35 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_network_acl_rule.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_network_acl_rule.py @@ -14,100 +14,117 @@ module: cs_network_acl_rule short_description: Manages network access control list (ACL) rules on Apache CloudStack based clouds. description: - Add, update and remove network ACL rules. -version_added: "2.4" -author: "René Moser (@resmo)" +version_added: '2.4' +author: René Moser (@resmo) options: network_acl: description: - Name of the network ACL. + type: str required: true aliases: [ acl ] cidr: description: - CIDR of the rule. - default: '0.0.0.0/0' + type: str + default: 0.0.0.0/0 rule_position: description: - The position of the network ACL rule. + type: int required: true aliases: [ number ] protocol: description: - Protocol of the rule choices: [ tcp, udp, icmp, all, by_number ] + type: str default: tcp protocol_number: description: - Protocol number from 1 to 256 required if I(protocol=by_number). + type: int start_port: description: - Start port for this rule. - Considered if I(protocol=tcp) or I(protocol=udp). + type: int aliases: [ port ] end_port: description: - End port for this rule. - Considered if I(protocol=tcp) or I(protocol=udp). - If not specified, equal I(start_port). + type: int icmp_type: description: - Type of the icmp message being sent. - Considered if I(protocol=icmp). + type: int icmp_code: description: - Error code for this icmp message. - Considered if I(protocol=icmp). + type: int vpc: description: - VPC the network ACL is related to. + type: str required: true traffic_type: description: - Traffic type of the rule. + type: str choices: [ ingress, egress ] default: ingress aliases: [ type ] action_policy: description: - Action policy of the rule. + type: str choices: [ allow, deny ] default: allow aliases: [ action ] tags: description: - 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. C(tags: [])." + - "If you want to delete all tags, set a empty list e.g. I(tags: [])." + type: list aliases: [ tag ] domain: description: - Domain the VPC is related to. + type: str account: description: - Account the VPC is related to. + type: str project: description: - Name of the project the VPC is related to. + type: str zone: description: - Name of the zone the VPC related to. - If not set, default zone is used. + type: str state: description: - State of the network ACL rule. + type: str default: present choices: [ present, absent ] poll_async: description: - Poll async jobs until job has finished. type: bool - default: 'yes' + default: yes extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' - name: create a network ACL rule, allow port 80 ingress - local_action: - module: cs_network_acl_rule + cs_network_acl_rule: network_acl: web rule_position: 1 vpc: my vpc @@ -115,10 +132,10 @@ EXAMPLES = ''' action_policy: allow port: 80 cidr: 0.0.0.0/0 + delegate_to: localhost - name: create a network ACL rule, deny port range 8000-9000 ingress for 10.20.0.0/16 - local_action: - module: cs_network_acl_rule + cs_network_acl_rule: network_acl: web rule_position: 1 vpc: my vpc @@ -127,10 +144,10 @@ EXAMPLES = ''' start_port: 8000 end_port: 8000 cidr: 10.20.0.0/16 + delegate_to: localhost - name: create a network ACL rule - local_action: - module: cs_network_acl_rule + cs_network_acl_rule: network_acl: web rule_position: 1 vpc: my vpc @@ -139,14 +156,15 @@ EXAMPLES = ''' start_port: 8000 end_port: 8000 cidr: 10.20.0.0/16 + delegate_to: localhost - name: remove a network ACL rule - local_action: - module: cs_network_acl_rule + cs_network_acl_rule: network_acl: web rule_position: 1 vpc: my vpc state: absent + delegate_to: localhost ''' RETURN = ''' @@ -219,7 +237,7 @@ vpc: tags: description: List of resource tags associated with the network ACL rule. returned: success - type: dict + type: list sample: '[ { "key": "foo", "value": "bar" } ]' domain: description: Domain the network ACL rule is related to. diff --git a/test/sanity/validate-modules/ignore.txt b/test/sanity/validate-modules/ignore.txt index cf784e588a..4cd23e83f7 100644 --- a/test/sanity/validate-modules/ignore.txt +++ b/test/sanity/validate-modules/ignore.txt @@ -99,8 +99,6 @@ 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_iso.py E323 -lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule.py E322 -lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule.py E324 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