New in version 2.0.
parameter | required | default | choices | comments |
---|---|---|---|---|
account | no | Account the vm is related to. | ||
api_http_method | no | get |
| HTTP method used. |
api_key | no | API key of the CloudStack API. | ||
api_region | no | cloudstack | Name of the ini section in the cloustack.ini file. | |
api_secret | no | Secret key of the CloudStack API. | ||
api_timeout | no | 10 | HTTP timeout. | |
api_url | no | URL of the CloudStack API e.g. https://cloud.example.com/client/api. | ||
domain | no | Domain the vm is related to. | ||
ip_address | yes | Public IP address the rule is assigned to. | ||
network (added in 2.3)
| no | Name of the network. | ||
open_firewall | no | Whether the firewall rule for public port should be created, while creating the new rule. Use cs_firewall for managing firewall rules. | ||
poll_async | no | True | Poll async jobs until job has finished. | |
private_end_port | no | End private port for this rule. If not specified equal private_port . | ||
private_port | yes | Start private port for this rule. | ||
project | no | Name of the project the vm is located in. | ||
protocol | no | tcp |
| Protocol of the port forwarding rule. |
public_end_port | no | End public port for this rule. If not specified equal public_port . | ||
public_port | yes | Start public port for this rule. | ||
state | no | present |
| State of the port forwarding rule. |
tags (added in 2.4)
| no | List of tags. Tags are a list of dictionaries having keys key and value .To delete all tags, set a empty list e.g. tags: [] .aliases: tag | ||
vm | no | Name of virtual machine which we make the port forwarding rule for. Required if state=present . | ||
vm_guest_ip | no | VM guest NIC secondary IP address for the port forwarding rule. | ||
vpc (added in 2.3)
| no | Name of the VPC. | ||
zone | no | Name of the zone in which the virtual machine is in. If not set, default zone is used. |
# 1.2.3.4:80 -> web01:8080 - local_action: module: cs_portforward ip_address: 1.2.3.4 vm: web01 public_port: 80 private_port: 8080 # forward SSH and open firewall - local_action: module: cs_portforward ip_address: '{{ public_ip }}' vm: '{{ inventory_hostname }}' public_port: '{{ ansible_ssh_port }}' private_port: 22 open_firewall: true # forward DNS traffic, but do not open firewall - local_action: module: cs_portforward ip_address: 1.2.3.4 vm: '{{ inventory_hostname }}' public_port: 53 private_port: 53 protocol: udp # remove ssh port forwarding - local_action: module: cs_portforward ip_address: 1.2.3.4 public_port: 22 private_port: 22 state: absent
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
vm_name | Name of the virtual machine. | success | string | web-01 |
vm_display_name | Display name of the virtual machine. | success | string | web-01 |
protocol | Protocol. | success | string | tcp |
network | Name of the network. | success | string | dmz |
tags | Tags related to the port forwarding. | success | list | [] |
public_port | Start port on the public IP address. | success | int | 80 |
public_end_port | End port on the public IP address. | success | int | 80 |
private_port | Start port on the virtual machine's IP address. | success | int | 80 |
vpc | Name of the VPC. | success | string | my_vpc |
private_end_port | End port on the virtual machine's IP address. | success | int | |
ip_address | Public IP address. | success | string | 1.2.3.4 |
id | UUID of the public IP address. | success | string | a6f7a5fc-43f8-11e5-a151-feff819cdc9f |
vm_guest_ip | IP of the virtual machine. | success | string | 10.101.65.152 |
Note
cs
library’s configuration method if credentials are not provided by the arguments api_url
, api_key
, api_secret
. Configuration is read from several locations, in the following order. - The CLOUDSTACK_ENDPOINT
, CLOUDSTACK_KEY
, CLOUDSTACK_SECRET
and CLOUDSTACK_METHOD
. CLOUDSTACK_TIMEOUT
environment variables. - A CLOUDSTACK_CONFIG
environment variable pointing to an .ini
file, - A cloudstack.ini
file in the current working directory. - A .cloudstack.ini
file in the users home directory. Optionally multiple credentials and endpoints can be specified using ini sections in cloudstack.ini
. Use the argument api_region
to select the section name, default section is cloudstack
. See https://github.com/exoscale/cs for more information.This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/cs_portforward_module.html