cs_network - Manages networks on Apache CloudStack based clouds.

New in version 2.0.

Synopsis

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 2.6
  • cs >= 0.6.10

Parameters

Parameter Choices/Defaults Comments
account
Account the network is related to.
acl
(added in 2.5)
The name of the access control list for the VPC network tier.
acl_type
    Choices:
  • account ←
  • domain
Access control type for the VPC network tier.
Only considered on create.
api_http_method
    Choices:
  • get
  • post
HTTP method used to query the API endpoint.
If not given, the CLOUDSTACK_METHOD env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
Fallback value is get if not specified.
api_key
API key of the CloudStack API.
If not given, the CLOUDSTACK_KEY env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
api_region Default:
cloudstack
Name of the ini section in the cloustack.ini file.
If not given, the CLOUDSTACK_REGION env variable is considered.
api_secret
Secret key of the CloudStack API.
If not set, the CLOUDSTACK_SECRET env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
api_timeout
HTTP timeout in seconds.
If not given, the CLOUDSTACK_TIMEOUT env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
Fallback value is 10 seconds if not specified.
api_url
URL of the CloudStack API e.g. https://cloud.example.com/client/api.
If not given, the CLOUDSTACK_ENDPOINT env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
cidr_ipv6
CIDR of IPv6 network, must be at least /64.
Only considered on create.
clean_up
bool
    Choices:
  • no ←
  • yes
Cleanup old network elements.
Only considered on state=restarted.
display_text
Display text of the network.
If not specified, name will be used as display_text.
domain
Domain the network is related to.
end_ip
The ending IPv4 address of the network belongs to.
If not specified, value of start_ip is used.
Only considered on create.
end_ipv6
The ending IPv6 address of the network belongs to.
If not specified, value of start_ipv6 is used.
Only considered on create.
gateway
The gateway of the network.
Required for shared networks and isolated networks when it belongs to a VPC.
Only considered on create.
gateway_ipv6
The gateway of the IPv6 network.
Required for shared networks.
Only considered on create.
isolated_pvlan
The isolated private VLAN for this network.
name
required
Name (case sensitive) of the network.
netmask
The netmask of the network.
Required for shared networks and isolated networks when it belongs to a VPC.
Only considered on create.
network_domain
The network domain.
network_offering
Name of the offering for the network.
Required if state=present.
poll_async
bool
    Choices:
  • no
  • yes ←
Poll async jobs until job has finished.
project
Name of the project the network to be deployed in.
start_ip
The beginning IPv4 address of the network belongs to.
Only considered on create.
start_ipv6
The beginning IPv6 address of the network belongs to.
Only considered on create.
state
    Choices:
  • present ←
  • absent
  • restarted
State of the network.
subdomain_access
bool

(added in 2.5)
    Choices:
  • no
  • yes
Defines whether to allow subdomains to use networks dedicated to their parent domain(s).
Should be used with acl_type=domain.
Only considered on create.
vlan
The ID or VID of the network.
vpc
Name of the VPC of the network.
zone
Name of the zone in which the network should be deployed.
If not set, default zone is used.

Notes

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.
  • A detailed guide about cloudstack modules can be found in the CloudStack Cloud Guide.
  • This module supports check mode.

Examples

- name: Create a network
  local_action:
    module: cs_network
    name: my network
    zone: gva-01
    network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService
    network_domain: example.com

- name: Create a VPC tier
  local_action:
    module: cs_network
    name: my VPC tier 1
    zone: gva-01
    vpc: my VPC
    network_offering: DefaultIsolatedNetworkOfferingForVpcNetworks
    gateway: 10.43.0.1
    netmask: 255.255.255.0
    acl: my web acl

- name: Update a network
  local_action:
    module: cs_network
    name: my network
    display_text: network of domain example.local
    network_domain: example.local

- name: Restart a network with clean up
  local_action:
    module: cs_network
    name: my network
    clean_up: yes
    state: restared

- name: Remove a network
  local_action:
    module: cs_network
    name: my network
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
account
string
success
Account the network is related to.

Sample:
example account
acl
string

(added in 2.5)
success
Name of the access control list for the VPC network tier.

Sample:
My ACL
acl_id
string

(added in 2.5)
success
ID of the access control list for the VPC network tier.

Sample:
dfafcd55-0510-4b8c-b6c5-b8cedb4cfd88
acl_type
string
success
Access type of the VPC network tier (Domain, Account).

Sample:
Account
broadcast_domain_type
string
success
Broadcast domain type of the network.

Sample:
Vlan
cidr
string
success
IPv4 network CIDR.

Sample:
10.101.64.0/24
cidr_ipv6
string
success
IPv6 network CIDR.

Sample:
2001:db8::/64
display_text
string
success
Display text of the network.

Sample:
web project
dns1
string
success
IP address of the 1st nameserver.

Sample:
1.2.3.4
dns2
string
success
IP address of the 2nd nameserver.

Sample:
1.2.3.4
domain
string
success
Domain the network is related to.

Sample:
ROOT
gateway
string
success
IPv4 gateway.

Sample:
10.101.64.1
gateway_ipv6
string
success
IPv6 gateway.

Sample:
2001:db8::1
id
string
success
UUID of the network.

Sample:
04589590-ac63-4ffc-93f5-b698b8ac38b6
is_persistent
boolean
success
Whether the network is persistent or not.

is_system
bool

(added in 2.5)
success
Whether the network is system related or not.

name
string
success
Name of the network.

Sample:
web project
netmask
string
success
IPv4 netmask.

Sample:
255.255.255.0
network_domain
string
success
The network domain

Sample:
example.local
network_offering
string
success
The network offering name.

Sample:
DefaultIsolatedNetworkOfferingWithSourceNatService
network_offering_availability
string

(added in 2.5)
success
The availability of the network offering the network is created from

Sample:
Optional
network_offering_conserve_mode
bool

(added in 2.5)
success
Whether the network offering has IP conserve mode enabled or not.

network_offering_display_text
string

(added in 2.5)
success
The network offering display text.

Sample:
Offering for Isolated Vpc networks with Source Nat service enabled
project
string
success
Name of project.

Sample:
Production
state
string
success
State of the network (Allocated, Implemented, Setup).

Sample:
Allocated
tags
dict
success
List of resource tags associated with the network.

Sample:
[ { "key": "foo", "value": "bar" } ]
traffic_type
string
success
Traffic type of the network.

Sample:
Guest
type
string
success
Type of the network.

Sample:
Isolated
zone
string
success
Name of zone.

Sample:
ch-gva-2


Status

This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

Author

  • René Moser (@resmo)

Hint

If you notice any issues in this documentation you can edit this document to improve it.