ngine_io.cloudstack.cs_portforward – Manages port forwarding rules on Apache CloudStack based clouds.
Note
This plugin is part of the ngine_io.cloudstack collection (version 2.2.2).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install ngine_io.cloudstack
.
To use it in a playbook, specify: ngine_io.cloudstack.cs_portforward
.
New in version 0.1.0: of ngine_io.cloudstack
Requirements
The below requirements are needed on the host that executes this module.
python >= 2.6
cs >= 0.9.0
Parameters
Parameter |
Comments |
---|---|
Account the vm is related to. |
|
HTTP method used to query the API endpoint. If not given, the Choices:
|
|
API key of the CloudStack API. If not given, the |
|
Secret key of the CloudStack API. If not set, the |
|
HTTP timeout in seconds. If not given, the Default: 10 |
|
URL of the CloudStack API e.g. https://cloud.example.com/client/api. If not given, the |
|
Verify CA authority cert file. If not given, the |
|
Domain the vm is related to. |
|
Public IP address the rule is assigned to. |
|
Name of the network. Required when forwarding ports in a VPC. |
|
Whether the firewall rule for public port should be created, while creating the new rule. Not supported when forwarding ports in a VPC. Use M(cs_firewall) for managing firewall rules. Choices:
|
|
Poll async jobs until job has finished. Choices:
|
|
End private port for this rule. If not specified equal private_port. |
|
Start private port for this rule. |
|
Name of the project the vm is located in. |
|
Protocol of the port forwarding rule. Choices:
|
|
End public port for this rule. If not specified equal public_port. |
|
Start public port for this rule. |
|
State of the port forwarding rule. Choices:
|
|
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: []. |
|
Name of virtual machine which we make the port forwarding rule for. Required if state=present. |
|
VM guest NIC secondary IP address for the port forwarding rule. |
|
Name of the VPC. |
|
Name of the zone in which the virtual machine is in. |
Notes
Note
A detailed guide about cloudstack modules can be found in the CloudStack Cloud Guide.
This module supports check mode.
Examples
- name: 1.2.3.4:80 -> web01:8080
ngine_io.cloudstack.cs_portforward:
ip_address: 1.2.3.4
zone: zone01
vm: web01
public_port: 80
private_port: 8080
- name: forward SSH and open firewall
ngine_io.cloudstack.cs_portforward:
ip_address: '{{ public_ip }}'
zone: zone01
vm: '{{ inventory_hostname }}'
public_port: '{{ ansible_ssh_port }}'
private_port: 22
open_firewall: true
- name: forward DNS traffic, but do not open firewall
ngine_io.cloudstack.cs_portforward:
ip_address: 1.2.3.4
zone: zone01
vm: '{{ inventory_hostname }}'
public_port: 53
private_port: 53
protocol: udp
- name: remove ssh port forwarding
ngine_io.cloudstack.cs_portforward:
ip_address: 1.2.3.4
zone: zone01
public_port: 22
private_port: 22
state: absent
- name: forward SSH in backend tier of VPC
ngine_io.cloudstack.cs_portforward:
ip_address: '{{ public_ip }}'
zone: zone01
vm: '{{ inventory_hostname }}'
public_port: '{{ ansible_ssh_port }}'
private_port: 22
vpc: myVPC
network: backend
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
UUID of the public IP address. Returned: success Sample: “a6f7a5fc-43f8-11e5-a151-feff819cdc9f” |
|
Public IP address. Returned: success Sample: “1.2.3.4” |
|
Name of the network. Returned: success Sample: “dmz” |
|
End port on the virtual machine’s IP address. Returned: success Sample: 80 |
|
Start port on the virtual machine’s IP address. Returned: success Sample: 80 |
|
Protocol. Returned: success Sample: “tcp” |
|
End port on the public IP address. Returned: success Sample: 80 |
|
Start port on the public IP address. Returned: success Sample: 80 |
|
Tags related to the port forwarding. Returned: success Sample: [] |
|
Display name of the virtual machine. Returned: success Sample: “web-01” |
|
IP of the virtual machine. Returned: success Sample: “10.101.65.152” |
|
Name of the virtual machine. Returned: success Sample: “web-01” |
|
Name of the VPC. Returned: success Sample: “my_vpc” |
Authors
René Moser (@resmo)