lixue323.vpc.ali_vpc (1.0.0) — module

Configure Alibaba Cloud virtual private cloud(VPC)

| "added in version" 2.8 of lixue323.vpc"

Authors: He Guimin (@xiaozhu36)

preview | supported by community

Install collection

Install with ansible-galaxy collection install lixue323.vpc:==1.0.0


Add to requirements.yml

  collections:
    - name: lixue323.vpc
      version: 1.0.0

Description

Create, Delete Alicloud virtual private cloud(VPC). It supports updating VPC description.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details.
- name: create a new vpc
  ali_vpc:
    cidr_block: '192.168.0.0/16'
    name: 'Demo_VPC'
    description: 'Demo VPC'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: choose the latest VPC as target when there are several vpcs with same name and cidr block
  ali_vpc:
    cidr_block: '192.168.0.0/16'
    name: 'Demo_VPC'
    recent: True
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: delete a vpc
  ali_vpc:
    state: absent
    cidr_block: '192.168.0.0/16'
    name: 'Demo_VPC'

Inputs

    
name:
    aliases:
    - vpc_name
    description:
    - The name to give your 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://. This is
      used in combination with C(cidr_block) to determine if a VPC already exists.
    required: true

tags:
    description:
    - A hash/dictionaries of vpc tags. C({"key":"value"})

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Whether or not to create, delete VPC.

recent:
    default: false
    description:
    - By default the module will not choose the recent one if there is another VPC with
      the same I(name) and I(cidr_block). Specify this as true if you want to target the
      recent VPC. There will be conflict when I(multi_ok=True) and I(recent=True).
    type: bool

vpc_id:
    description:
    - (Deprecated) The ID of a VPC.

profile:
    description:
    - This is the Alicloud profile name as set in the shared credentials file. It can
      also be sourced from the ALICLOUD_PROFILE environment variable.
    type: str

multi_ok:
    default: false
    description:
    - By default the module will not create another VPC if there is another VPC with the
      same name and CIDR block. Specify this as true if you want duplicate VPCs created.
    type: bool

cidr_block:
    aliases:
    - cidr
    description:
    - The primary CIDR of the VPC. This is used in conjunction with the C(name) to ensure
      idempotence.
    required: true

purge_tags:
    default: false
    description:
    - Delete existing tags on the vpc that are not specified in the task. If True, it
      means you have to specify all the desired tags on each task affecting a vpc.
    type: bool

user_cidrs:
    description:
    - List of user custom cidr in the VPC. It no more than three.

description:
    description:
    - The description of VPC, which is a string of 2 to 256 characters. It cannot begin
      with http:// or https://.

ecs_role_name:
    aliases:
    - role_name
    description:
    - The RAM Role Name attached on a ECS instance for API operations. You can retrieve
      this from the 'Access Control' section of the Alibaba Cloud console.
    - If you're running Ansible from an ECS instance with RAM Instance using RAM Role,
      Ansible will just access the metadata U(http://100.100.100.200/latest/meta-data/ram/security-credentials/<ecs_role_name>)
      to obtain the STS credential. This is a preferred approach over any other when running
      in ECS as you can avoid hard coding credentials. Instead these are leased on-the-fly
      by Ansible which reduces the chance of leakage.
    type: str

alicloud_region:
    aliases:
    - region
    - region_id
    description:
    - The Alibaba Cloud region to use. If not specified then the value of environment
      variable C(ALICLOUD_REGION), C(ALICLOUD_REGION_ID) will be used instead.
    required: true
    type: str

alicloud_access_key:
    aliases:
    - access_key_id
    - access_key
    description:
    - Alibaba Cloud access key. If not set then the value of environment variable C(ALICLOUD_ACCESS_KEY),
      C(ALICLOUD_ACCESS_KEY_ID) will be used instead.
    type: str

alicloud_secret_key:
    aliases:
    - secret_access_key
    - secret_key
    description:
    - Alibaba Cloud secret key. If not set then the value of environment variable C(ALICLOUD_SECRET_KEY),
      C(ALICLOUD_SECRET_ACCESS_KEY) will be used instead.
    type: str

alicloud_assume_role:
    aliases:
    - assume_role
    description:
    - If provided with a role ARN, Ansible will attempt to assume this role using the
      supplied credentials.
    - The nested assume_role block supports I(alicloud_assume_role_arn), I(alicloud_assume_role_session_name),
      I(alicloud_assume_role_session_expiration) and I(alicloud_assume_role_policy)
    type: dict

alicloud_security_token:
    aliases:
    - security_token
    description:
    - The Alibaba Cloud security token. If not specified then the value of environment
      variable C(ALICLOUD_SECURITY_TOKEN) will be used instead.
    type: str

shared_credentials_file:
    description:
    - This is the path to the shared credentials file. It can also be sourced from the
      ALICLOUD_SHARED_CREDENTIALS_FILE environment variable.
    - If this is not set and a profile is specified,  ~/.aliyun/config.json will be used.
    type: str

alicloud_assume_role_arn:
    aliases:
    - assume_role_arn
    description:
    - The Alibaba Cloud role_arn. The ARN of the role to assume. If ARN is set to an empty
      string, it does not perform role switching. It supports environment variable ALICLOUD_ASSUME_ROLE_ARN.
      ansible will execute with provided credentials.
    type: str

alicloud_assume_role_session_name:
    aliases:
    - assume_role_session_name
    description:
    - The Alibaba Cloud session_name. The session name to use when assuming the role.
      If omitted, 'ansible' is passed to the AssumeRole call as session name. It supports
      environment variable ALICLOUD_ASSUME_ROLE_SESSION_NAME
    type: str

alicloud_assume_role_session_expiration:
    aliases:
    - assume_role_session_expiration
    description:
    - The Alibaba Cloud session_expiration. The time after which the established session
      for assuming role expires. Valid value range 900-3600 seconds. Default to 3600 (in
      this case Alicloud use own default value). It supports environment variable ALICLOUD_ASSUME_ROLE_SESSION_EXPIRATION
    type: int

Outputs

vpc:
  contains:
    cidr_block:
      description: The CIDR of the VPC
      returned: always
      sample: 10.0.0.0/8
      type: string
    creation_time:
      description: The time the VPC was created.
      returned: always
      sample: '2018-06-24T15:14:45+00:00'
      type: string
    description:
      description: The VPC description.
      returned: always
      sample: my ansible vpc
      type: string
    id:
      description: alias of 'vpc_id'.
      returned: always
      sample: vpc-c2e00da5
      type: string
    is_default:
      description: indicates whether this is the default VPC
      returned: always
      sample: false
      type: bool
    state:
      description: state of the VPC
      returned: always
      sample: available
      type: string
    tags:
      description: tags attached to the VPC, includes name
      returned: always
      sample: null
      type: complex
    user_cidrs:
      description: The custom CIDR of the VPC
      returned: always
      sample: []
      type: list
    vpc_id:
      description: VPC resource id
      returned: always
      sample: vpc-c2e00da5
      type: string
    vpc_name:
      description: Name of the VPC
      returned: always
      sample: my-vpc
      type: string
    vrouter_id:
      description: The ID of virtual router which in the VPC
      returned: always
      sample: available
      type: string
    vswitch_ids:
      description: List IDs of virtual switch which in the VPC
      returned: always
      sample:
      - vsw-123cce3
      - vsw-34cet4v
      type: list
  description: info about the VPC that was created or deleted
  returned: always
  type: complex