hwceco.hwcollection.hwc_vpc_subnet – Creates a resource of Vpc/Subnet in Huawei Cloud

Note

This plugin is part of the hwceco.hwcollection collection (version 1.0.5).

To install it use: ansible-galaxy collection install hwceco.hwcollection.

To use it in a playbook, specify: hwceco.hwcollection.hwc_vpc_subnet.

New in version 1.0.0: of hwceco.hwcollection

Synopsis

  • Creates and manages a resource of Vpc/Subnet in Huawei Cloud.

Requirements

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

  • huaweicloudsdkcore >= 3.0.47

  • huaweicloudsdkvpc >= 3.0.47

Parameters

Parameter Choices/Defaults Comments
access_key
string / required
Specifies the access key of the HuaweiCloud to use.
availability_zone
string
Specifies the AZ to which the subnet belongs.
cidr
string / required
Specifies the subnet CIDR block. The value must be within the VPC CIDR block and be in CIDR format. The subnet mask cannot be greater than 28.
cloud
string
Default:
"myhuaweicloud.com"
Specifies the endpoint of the cloud. Required if you are using other cloud supported by Huaweicloud.
dhcp_enable
boolean
    Choices:
  • no
  • yes ←
Specifies whether DHCP is enabled for the subnet.
dns_address
list / elements=string
Specifies the DNS server addresses for subnet. The address in the head will be used first.
filters
list / elements=string / required
A list of filters to apply when deciding whether existing resources match and should be altered. The item of filters is the name of input options.
gateway_ip
string / required
Specifies the gateway of the subnet. The value must be an IP address in the subnet.
identity_endpoint
string
Default:
"https://iam.myhuaweicloud.com:443/v3"
Specifies the Identity authentication URL. Required if you are using other cloud supported by Huaweicloud.
ipv6_enable
boolean
    Choices:
  • no ←
  • yes
Specifies whether the IPv6 function is enabled for the subnet.
name
string / required
Specifies the subnet name. The value is a string of 1 to 64 characters that can contain letters, digits, underscores _, hyphens (-), and periods (.).
project_id
string / required
Specifies the of ID of the project to login with.
region
string / required
Specifies the Huawei Cloud region.
secret_key
string / required
Specifies the secret key of the HuaweiCloud to use.
state
string
    Choices:
  • present ←
  • absent
Whether the given object should exist in Huawei Cloud.
tags
dictionary
Specifies the key/value pairs to associate with the subnet.
timeouts
dictionary
The timeouts for each operations.
create
string
Default:
"15m"
The timeouts for create operation.
update
string
Default:
"15m"
The timeouts for update operation.
vpc_id
string / required
Specifies the ID of the VPC to which the subnet belongs.

Notes

Note

  • For authentication, you can set access_key using the `ANSIBLE_HWC_ACCESS_KEY’ env variable.

  • For authentication, you can set secret_key using the `ANSIBLE_HWC_SECRET_KEY’ env variable.

  • For authentication, you can set project_id using the `ANSIBLE_HWC_PROJECT_ID’ env variable.

  • For authentication, you can set region using the `ANSIBLE_HWC_REGION’ env variable.

  • For authentication, you can set identity_endpoint using the `ANSIBLE_HWC_IDENTITY_ENDPOINT’ env variable.

  • For authentication, you can set cloud using the `ANSIBLE_HWC_CLOUD’ env variable.

  • Environment variables values will only be used if the playbook values are not set.

Examples

# create subnet
- name: create vpc
  hwc_vpc:
      cidr: "192.168.100.0/24"
      name: "ansible_network_vpc_test"
  register: vpc
- name: create subnet
  hwc_vpc_subnet:
      filters:
          - "name"
      vpc_id: "{{ vpc.state.id }}"
      cidr: "192.168.100.0/26"
      gateway_ip: "192.168.100.32"
      name: "ansible_network_subnet_test"
      dhcp_enable: True

Return Values

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

Key Returned Description
availability_zone
string
success
Specifies the AZ to which the subnet belongs.

cidr
string
success
Specifies the subnet CIDR block. The value must be within the VPC CIDR block and be in CIDR format. The subnet mask cannot be greater than 28.

dhcp_enable
boolean
success
Specifies whether DHCP is enabled for the subnet.

dns_address
list / elements=string
success
Specifies the DNS server addresses for subnet. Note that the address in the head will be used first.

gateway_ip
string
success
Specifies the gateway of the subnet. The value must be an IP address in the subnet.

ipv6_enable
boolean
success
Specifies whether the IPv6 function is enabled for the subnet.

name
string
success
Specifies the subnet name. The value is a string of 1 to 64 characters that can contain letters, digits, underscores _, hyphens (-), and periods (.).

tags
dictionary
success
Specifies the key/value pairs to associate with the subnet.

vpc_id
string
success
Specifies the ID of the VPC to which the subnet belongs.



Authors

  • Huawei (@huaweicloud)