Documentation

alicloud_vpc - Create, Query or Delete Vpc. Query Vswitch.

DEPRECATED

Removed in Ansible:
 version: 1.5.0
Why:Alibaba Cloud module name prefix ‘ali’ will be more concise
Alternative:Use ali_vpc instead

Synopsis

  • Create, Query or Delete Vpc, and Query vswitch which in it.

Requirements

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

  • footmark >= 1.1.16
  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
alicloud_access_key
Aliyun Cloud access key. If not set then the value of environment variable ALICLOUD_ACCESS_KEY, ALICLOUD_ACCESS_KEY_ID will be used instead.

aliases: access_key_id, access_key
alicloud_region
The Aliyun Cloud region to use. If not specified then the value of environment variable ALICLOUD_REGION, ALICLOUD_REGION_ID will be used instead.

aliases: region, region_id
alicloud_secret_key
Aliyun Cloud secret key. If not set then the value of environment variable ALICLOUD_SECRET_KEY, ALICLOUD_SECRET_ACCESS_KEY will be used instead.

aliases: secret_access_key, secret_key
alicloud_security_token
The Aliyun Cloud security token. If not specified then the value of environment variable ALICLOUD_SECURITY_TOKEN will be used instead.

aliases: security_token
cidr_block
    Choices:
  • 10.0.0.0/8
  • 172.16.0.0/12 ←
  • 192.168.0.0/16
The CIDR block representing the vpc. The value can be subnet block of its choices. It is required when creating a vpc.

aliases: cidr
description
The description of VPC, which is a string of 2 to 256 characters. It cannot begin with http:// or https://.
is_default
bool
    Choices:
  • no
  • yes
When retrieving vpc, it can mark the VPC is created by system.
state
    Choices:
  • present ←
  • absent
  • list
Whether or not to create, delete or query VPC.
user_cidr
User custom cidr in the VPC. Multiple cidr should be separated by comma, and no more than three.
vpc_id
The ID of a VPC. It required when managing an existing VPC. Such as deleting vpc and querying vpc attribute.
vpc_name
The name of VPC, which is a string of 2 to 128 Chinese or English characters. It must begin with an uppercase/lowercase letter or a Chinese character and can contain numerals, "_" or "-". It cannot begin with http:// or https://.

aliases: name

Notes

Note

  • There will be launch a virtual router along with creating a vpc successfully.
  • There is only one virtual router in one vpc and one route table in one virtual router.
  • If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence ALICLOUD_ACCESS_KEY or ALICLOUD_ACCESS_KEY_ID, ALICLOUD_SECRET_KEY or ALICLOUD_SECRET_ACCESS_KEY, ALICLOUD_REGION or ALICLOUD_REGION_ID, ALICLOUD_SECURITY_TOKEN
  • ALICLOUD_REGION or ALICLOUD_REGION_ID can be typically be used to specify the ALICLOUD region, when required, but this can also be configured in the footmark config file

Examples

#
# provisioning to create vpc in VPC
#

# basic provisioning example to create vpc in VPC
- name: create vpc
  hosts: localhost
  connection: local
  vars:
    alicloud_region: cn-hongkong
    state: present
    cidr_block: 192.168.0.0/16
    vpc_name: Demo_VPC
    description: Demo VPC
  tasks:
    - name: create vpc
      alicloud_vpc:
        alicloud_region: '{{ alicloud_region }}'
        state: '{{ state }}'
        cidr_block: '{{ cidr_block }}'
        vpc_name: '{{ vpc_name }}'
        description: '{{ description }}'
      register: result
    - debug: var=result

# basic provisioning example to delete vpc
- name: delete vpc
  hosts: localhost
  connection: local
  vars:
    alicloud_region: cn-hongkong
  tasks:
    - name: delete vpc
      alicloud_vpc:
        alicloud_region: '{{ alicloud_region }}'
        state: absent
        vpc_id: xxxxxxxxxx
      register: result
    - debug: var=result

Return Values

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

Key Returned Description
vpc
complex
always
info about the VPC that was created or deleted

  description
string
always
The VPC description.

Sample:
my ansible vpc
  tags
complex
always
tags attached to the VPC, includes name

  vpc_name
string
always
Name of the VPC

Sample:
my-vpc
  creation_time
string
always
The time the VPC was created.

Sample:
2018-06-24 15:14:45
  id
string
always
alias of 'vpc_id'.

Sample:
vpc-c2e00da5
  is_default
bool
always
indicates whether this is the default VPC

  state
string
always
state of the VPC

Sample:
available
  vrouter_id
string
always
The ID of virtual router which in the VPC

Sample:
available
  vpc_id
string
always
VPC resource id

Sample:
vpc-c2e00da5
  vswitch_ids
list
always
List IDs of virtual switch which in the VPC

Sample:
['vsw-123cce3', 'vsw-34cet4v']
  cidr_block
string
always
The CIDR of the VPC

Sample:
10.0.0.0/8
  user_cidrs
list
always
The custom CIDR of the VPC



Status

This module is flagged as deprecated and will be removed in version 1.5.0. For more information see DEPRECATED.

Author

  • He Guimin (@xiaozhu36)

Hint

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