community.general.hwc_vpc_subnet – Creates a resource of Vpc/Subnet in Huawei Cloud

Note

This plugin is part of the community.general collection (version 1.3.6).

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.hwc_vpc_subnet.

New in version 0.2.0: of community.general

Synopsis

  • subnet management.

Requirements

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

  • keystoneauth1 >= 3.6.0

Parameters

Parameter Choices/Defaults Comments
availability_zone
string
Specifies the AZ to which the subnet belongs. Cannot be changed after creating the subnet.
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. Cannot be changed after creating the subnet.
dhcp_enable
boolean
    Choices:
  • no
  • yes
Specifies whether DHCP is enabled for the subnet. The value can be true (enabled) or false(disabled), and default value is true. If this parameter is set to false, newly created ECSs cannot obtain IP addresses, and usernames and passwords cannot be injected using Cloud-init.
dns_address
list / elements=string
Specifies the DNS server addresses for subnet. The address in the head will be used first.
domain
string / required
The name of the Domain to scope to (Identity v3). (currently only domain names are supported, and not domain IDs).
gateway_ip
string / required
Specifies the gateway of the subnet. The value must be an IP address in the subnet. Cannot be changed after creating the subnet.
id
string
The id of resource to be managed.
identity_endpoint
string / required
The Identity authentication URL.
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 (.).
password
string / required
The password to login with.
project
string / required
The name of the Tenant (Identity v2) or Project (Identity v3). (currently only project names are supported, and not project IDs).
region
string
The region to which the project belongs.
state
string
    Choices:
  • present ←
  • absent
Whether the given object should exist in Huawei Cloud.
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.
user
string / required
The user name to login with (currently only user names are supported, and not user IDs).
vpc_id
string / required
Specifies the ID of the VPC to which the subnet belongs. Cannot be changed after creating the subnet.

Notes

Note

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

  • For authentication, you can set user using the ANSIBLE_HWC_USER env variable.

  • For authentication, you can set password using the ANSIBLE_HWC_PASSWORD env variable.

  • For authentication, you can set domain using the ANSIBLE_HWC_DOMAIN env variable.

  • For authentication, you can set project using the ANSIBLE_HWC_PROJECT env variable.

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

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

Examples

# create subnet
- name: Create vpc
  hwc_network_vpc:
    cidr: "192.168.100.0/24"
    name: "ansible_network_vpc_test"
  register: vpc
- name: Create subnet
  community.general.hwc_vpc_subnet:
    vpc_id: "{{ vpc.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. The value can be true (enabled) or false(disabled), and default value is true. If this parameter is set to false, newly created ECSs cannot obtain IP addresses, and usernames and passwords cannot be injected using Cloud-init.

dns_address
list / elements=string
success
Specifies the DNS server addresses for subnet. 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.

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 (.).

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



Authors

  • Huawei Inc. (@huaweicloud)