W3cubDocs

/Ansible

community.digitalocean.digital_ocean_vpc – Create and delete DigitalOcean VPCs

Note

This plugin is part of the community.digitalocean collection (version 1.11.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

Synopsis

  • This module can be used to create and delete DigitalOcean VPCs.

Parameters

Parameter Choices/Defaults Comments
default
boolean
    Choices:
  • no
  • yes
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 default field cannot be unset from true.
If you want to set a new default VPC network, update the default field of another VPC network in the same region.
The previous network's default field will be set to false when a new default VPC has been defined.
description
string
A free-form text field for describing the VPC's purpose.
It may be a maximum of 255 characters.
ip_range
string
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.
name
string / required
The name of the VPC.
Must be unique and contain alphanumeric characters, dashes, and periods only.
oauth_token
string
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'

aliases: api_token
region
string
The slug identifier for the region where the VPC will be created.
state
string
    Choices:
  • present
  • absent
Whether the VPC should be present (created) or absent (deleted).
timeout
integer
Default:
30
The timeout in seconds used for polling DigitalOcean's API.
validate_certs
boolean
    Choices:
  • no
  • yes
If set to no, the SSL certificates will not be validated.
This should only set to no used on personally controlled sites using self-signed certificates.

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 Returned Description
data
dictionary
success
A DigitalOcean VPC.

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)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/digitalocean/digital_ocean_vpc_module.html