New in version 2.0.
Create, update and remove port forwarding rules.
- python >= 2.6
- cs >= 0.6.10
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. | ||
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. |
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. | ||
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 Common 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 |
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 |
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
Ansible uses the 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.
Note
This module supports check mode.
For more information on what this means please read Extras Modules
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.