community.digitalocean.digital_ocean_vpc – Create and delete DigitalOcean VPCs
Note
This plugin is part of the community.digitalocean collection (version 1.13.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 version 1.7.0: of community.digitalocean
Parameters
Parameter |
Comments |
---|---|
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: 30 |
|
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: {“created_at”: “2021-06-17T11:43:12.12121565Z”, “default”: false, “description”: “”, “id”: “a3b72d97-192f-4984-9d71-08a5faf2e0c7”, “ip_range”: “10.116.16.0/20”, “name”: “testvpc1”, “region”: “nyc1”, “urn”: “do:vpc:a3b72d97-192f-4984-9d71-08a5faf2e0c7”} |
Authors
Mark Mercado (@mamercad)