community.digitalocean.digital_ocean_vpc module – Create and delete DigitalOcean VPCs
Note
This module is part of the community.digitalocean collection (version 1.22.0).
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 community.digitalocean
.
To use it in a playbook, specify: community.digitalocean.digital_ocean_vpc
.
New in community.digitalocean 1.7.0
Synopsis
This module can be used to create and delete DigitalOcean VPCs.
Parameters
Parameter |
Comments |
---|---|
DigitalOcean API base url. Default: |
|
A boolean value indicating whether or not the VPC is the default network for the region. All applicable resources are placed into the default VPC network unless otherwise specified during their creation. The If you want to set a new default VPC network, update the The previous network’s Choices:
|
|
A free-form text field for describing the VPC’s purpose. It may be a maximum of 255 characters. |
|
The requested range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be smaller than /24 nor larger than /16. If no IP range is specified, a /20 network range is generated that won’t conflict with other VPC networks in your account. |
|
The name of the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only. |
|
DigitalOcean OAuth token. There are several other environment variables which can be used to provide this value. i.e., - ‘DO_API_TOKEN’, ‘DO_API_KEY’, ‘DO_OAUTH_TOKEN’ and ‘OAUTH_TOKEN’ |
|
The slug identifier for the region where the VPC will be created. |
|
Whether the VPC should be present (created) or absent (deleted). Choices:
|
|
The timeout in seconds used for polling DigitalOcean’s API. Default: |
|
If set to This should only set to Choices:
|
Examples
- name: Create a VPC
community.digitalocean.digital_ocean_vpc:
state: present
name: myvpc1
region: nyc1
- name: Create a VPC (choose IP range)
community.digitalocean.digital_ocean_vpc:
state: present
name: myvpc1
region: nyc1
ip_range: 192.168.192.0/24
- name: Update a VPC (make it default)
community.digitalocean.digital_ocean_vpc:
state: present
name: myvpc1
region: nyc1
default: true
- name: Update a VPC (change description)
community.digitalocean.digital_ocean_vpc:
state: present
name: myvpc1
region: nyc1
description: myvpc
- name: Delete a VPC
community.digitalocean.digital_ocean_vpc:
state: absent
name: myvpc1
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
A DigitalOcean VPC. Returned: success Sample: |