cs_network – Manages networks on Apache CloudStack based clouds

Synopsis

  • Create, update, restart and delete networks.

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
string
Account the network is related to.
acl
string
added in 2.5
The name of the access control list for the VPC network tier.
acl_type
string
    Choices:
  • account
  • domain
Access control type for the network.
If not specified, Cloudstack will default to account for isolated networks
and domain for shared networks.
Only considered on create.
api_http_method
string
    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
string
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
string
Default:
"cloudstack"
Name of the ini section in the cloustack.ini file.
If not given, the CLOUDSTACK_REGION env variable is considered.
api_secret
string
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
integer
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
string
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
string
CIDR of IPv6 network, must be at least /64.
Only considered on create.
clean_up
boolean
    Choices:
  • no ←
  • yes
Cleanup old network elements.
Only considered on state=restarted.
display_text
string
Display text of the network.
If not specified, name will be used as display_text.
domain
string
Domain the network is related to.
end_ip
string
The ending IPv4 address of the network belongs to.
If not specified, value of start_ip is used.
Only considered on create.
end_ipv6
string
The ending IPv6 address of the network belongs to.
If not specified, value of start_ipv6 is used.
Only considered on create.
gateway
string
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
string
The isolated private VLAN for this network.
name
string / required
Name (case sensitive) of the network.
netmask
string
The netmask of the network.
Required for shared networks and isolated networks when it belongs to a VPC.
Only considered on create.
network_domain
string
The network domain.
network_offering
string
Name of the offering for the network.
Required if state=present.
poll_async
boolean
    Choices:
  • no
  • yes ←
Poll async jobs until job has finished.
project
string
Name of the project the network to be deployed in.
start_ip
string
The beginning IPv4 address of the network belongs to.
Only considered on create.
start_ipv6
string
The beginning IPv6 address of the network belongs to.
Only considered on create.
state
string
    Choices:
  • present ←
  • absent
  • restarted
State of the network.
subdomain_access
boolean
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.
tags
list
added in 2.9
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
vlan
string
The ID or VID of the network.
vpc
string
Name of the VPC of the network.
zone
string
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
  cs_network:
    name: my network
    zone: gva-01
    network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService
    network_domain: example.com
  delegate_to: localhost

- name: Create a VPC tier
  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
  delegate_to: localhost

- name: Update a 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
  cs_network:
    name: my network
    clean_up: yes
    state: restarted
  delegate_to: localhost

- name: Remove a network
  cs_network:
    name: my network
    state: absent
  delegate_to: localhost

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 network (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
if available
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
if available
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
boolean
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
boolean
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
list
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
vpc
string
if available
Name of the VPC.

Sample:
My VPC
zone
string
success
Name of zone.

Sample:
ch-gva-2


Status

Authors

  • René Moser (@resmo)

Hint

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