hwceco.hwcollection.hwc_ecs_instance – Creates a resource of Ecs/Instance 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_ecs_instance.

New in version 1.0.0: of hwceco.hwcollection

Synopsis

  • Creates and manages a resource of Ecs/Instance in Huawei Cloud

Requirements

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

  • huaweicloudsdkcore >= 3.0.47

  • huaweicloudsdkecs >= 3.0.47

Parameters

Parameter Choices/Defaults Comments
access_key
string / required
Specifies the access key of the HuaweiCloud to use.
admin_pass
string
Specifies the initial login password of the administrator account for logging in to an ECS using password authentication. The Linux administrator is root, and the Windows administrator is Administrator. Password complexity requirements, consists of 8 to 26 characters. The password must contain at least three of the following character types "uppercase letters, lowercase letters, digits, and special characters (!@$%^-_=+[{}]:,./?)". The password cannot contain the username or the username in reverse. The Windows ECS password cannot contain the username, the username in reverse, or more than two consecutive characters in the username.
availability_zone
string / required
Specifies the name of the AZ where the ECS is located.
cloud
string
Default:
"myhuaweicloud.com"
Specifies the endpoint of the cloud. Required if you are using other cloud supported by Huaweicloud.
data_volumes
list / elements=dictionary
Specifies the data disks of ECS instance.
device
string
Specifies the disk device name.
volume_id
string / required
Specifies the disk ID.
description
string
Specifies the description of an ECS, which is a null string by default. Can contain a maximum of 85 characters. Cannot contain special characters, such as < and >.
eip_id
string
Specifies the ID of the elastic IP address assigned to the ECS. Only elastic IP addresses in the DOWN state can be assigned.
enterprise_project_id
string
Specifies the ID of the enterprise project to which the ECS belongs.
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.
flavor_name
string / required
Specifies the name of the system flavor.
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.
image_id
string / required
Specifies the ID of the system image.
name
string / required
Specifies the ECS name. Value requirements: Consists of 1 to 64 characters, including letters, digits, underscores _, hyphens (-), periods (.).
nics
list / elements=dictionary / required
Specifies the NIC information of the ECS. Constraints the network of the NIC must belong to the VPC specified by vpc_id. A maximum of 12 NICs can be attached to an ECS.
ip_address
string / required
Specifies the IP address of the NIC. The value is an IPv4 address. Its value must be an unused IP address in the network segment of the subnet.
subnet_id
string / required
Specifies the ID of subnet.
project_id
string / required
Specifies the of ID of the project to login with.
region
string / required
Specifies the Huawei Cloud region.
root_volume
dictionary / required
Specifies the configuration of the ECS's system disks.
size
integer
Specifies the system disk size, in GB. The value range is 1 to 1024. The system disk size must be greater than or equal to the minimum system disk size supported by the image (min_disk attribute of the image). If this parameter is not specified or is set to 0, the default system disk size is the minimum value of the system disk in the image (min_disk attribute of the image).
snapshot_id
string
Specifies the snapshot ID or ID of the original data disk contained in the full-ECS image.
volume_type
string / required
Specifies the ECS system disk type.
SATA is common I/O disk type.
SAS is high I/O disk type.
SSD is ultra-high I/O disk type.
co-p1 is high I/O (performance-optimized I) disk type.
uh-l1 is ultra-high I/O (latency-optimized) disk type.
NOTE is For HANA, HL1, and HL2 ECSs, use co-p1 and uh-l1 disks. For other ECSs, do not use co-p1 or uh-l1 disks.
secret_key
string / required
Specifies the secret key of the HuaweiCloud to use.
security_groups
list / elements=string
Specifies the security groups of the ECS. If this parameter is left blank, the default security group is bound to the ECS by default.
server_metadata
dictionary
Specifies the metadata of ECS to be created.
server_tags
dictionary
Specifies the tags of an ECS. When you create ECSs, one ECS supports up to 10 tags.
ssh_key_name
string
Specifies the name of the SSH key used for logging in to the ECS.
state
string
    Choices:
  • present ←
  • absent
Whether the given object should exist in Huawei Cloud.
timeouts
dictionary
The timeouts for each operations.
create
string
Default:
"30m"
The timeouts for create operation.
delete
string
Default:
"30m"
The timeouts for delete operation.
update
string
Default:
"30m"
The timeouts for update operation.
user_data
string
Specifies the user data to be injected during the ECS creation process. Text, text files, and gzip files can be injected. The content to be injected must be encoded with base64. The maximum size of the content to be injected (before encoding) is 32 KB. For Linux ECSs, this parameter does not take effect when adminPass is used. Examples are provided as follows 'Linux #! /bin/bash echo user_test &gt;&gt; /home/user.txt Windows rem cmd echo 111 &gt; c:aa.tx.'
vpc_id
string / required
Specifies the ID of the VPC to which the ECS 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 an ecs instance
- name: create a vpc
  hwc_network_vpc:
    cidr: "192.168.100.0/24"
    name: "ansible_network_vpc_test"
  register: vpc
- name: create a subnet
  hwc_vpc_subnet:
    gateway_ip: "192.168.100.32"
    name: "ansible_network_subnet_test"
    dhcp_enable: true
    vpc_id: "{{ vpc.state.id }}"
    filters:
      - "name"
    cidr: "192.168.100.0/26"
  register: subnet
- name: create a eip
  hwc_vpc_eip:
    dedicated_bandwidth:
      charge_mode: "traffic"
      name: "ansible_test_dedicated_bandwidth"
      size: 1
    type: "5_bgp"
    filters:
      - "type"
      - "dedicated_bandwidth"
  register: eip
- name: create a disk
  hwc_evs_disk:
    filters:
      - "name"
    availability_zone: "cn-north-1a"
    name: "ansible_evs_disk_test"
    volume_type: "SATA"
    size: 10
  register: disk
- name: create an instance
  hwc_ecs_instance:
    data_volumes:
      - volume_id: "{{ disk.state.id }}"
    eip_id: "{{ eip.state.id }}"
    name: "ansible_ecs_instance_test"
    availability_zone: "cn-north-1a"
    nics:
      - subnet_id: "{{ subnet.state.id }}"
        ip_address: "192.168.100.33"
      - subnet_id: "{{ subnet.state.id }}"
        ip_address: "192.168.100.34"
    server_tags:
      my_server: "my_server"
    image_id: "8da46d6d-6079-4e31-ad6d-a7167efff892"
    flavor_name: "s3.small.1"
    filters:
      - "name"
    vpc_id: "{{ vpc.state.id }}"
    root_volume:
      volume_type: "SAS"

Return Values

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

Key Returned Description
admin_pass
string
success
Specifies the initial login password of the administrator account for logging in to an ECS using password authentication. The Linux administrator is root, and the Windows administrator is Administrator. Password complexity requirements consists of 8 to 26 characters. The password must contain at least three of the following character types "uppercase letters, lowercase letters, digits, and special characters (!@$%^-_=+[{}]:,./?)". The password cannot contain the username or the username in reverse. The Windows ECS password cannot contain the username, the username in reverse, or more than two consecutive characters in the username.

availability_zone
string
success
Specifies the name of the AZ where the ECS is located.

config_drive
string
success
Specifies the configuration driver.

created
string
success
Specifies the time when an ECS was created.

data_volumes
list / elements=dictionary
success
Specifies the data disks of ECS instance.

 
device
string
success
Specifies the disk device name.

 
volume_id
string
success
Specifies the disk ID.

description
string
success
Specifies the description of an ECS, which is a null string by default. Can contain a maximum of 85 characters. Cannot contain special characters, such as < and >.

disk_config_type
string
success
Specifies the disk configuration type. MANUAL is The image space is not expanded. AUTO is the image space of the system disk will be expanded to be as same as the flavor.

eip_id
string
success
Specifies the ID of the elastic IP address assigned to the ECS. Only elastic IP addresses in the DOWN state can be assigned.

enterprise_project_id
string
success
Specifies the ID of the enterprise project to which the ECS belongs.

flavor_name
string
success
Specifies the name of the system flavor.

host_name
string
success
Specifies the host name of the ECS.

image_id
string
success
Specifies the ID of the system image.

image_name
string
success
Specifies the image name of the ECS.

name
string
success
Specifies the ECS name. Value requirements "Consists of 1 to 64 characters, including letters, digits, underscores _, hyphens (-), periods (.)".

nics
list / elements=dictionary
success
Specifies the NIC information of the ECS. The network of the NIC must belong to the VPC specified by vpc_id. A maximum of 12 NICs can be attached to an ECS.

 
ip_address
string
success
Specifies the IP address of the NIC. The value is an IPv4 address. Its value must be an unused IP address in the network segment of the subnet.

 
port_id
string
success
Specifies the port ID corresponding to the IP address.

 
subnet_id
string
success
Specifies the ID of subnet.

power_state
integer
success
Specifies the power status of the ECS.

root_volume
dictionary
success
Specifies the configuration of the ECS's system disks.

 
device
string
success
Specifies the disk device name.

 
size
integer
success
Specifies the system disk size, in GB. The value range is 1 to 1024. The system disk size must be greater than or equal to the minimum system disk size supported by the image (min_disk attribute of the image). If this parameter is not specified or is set to 0, the default system disk size is the minimum value of the system disk in the image (min_disk attribute of the image).

 
snapshot_id
string
success
Specifies the snapshot ID or ID of the original data disk contained in the full-ECS image.

 
volume_id
string
success
Specifies the disk ID.

 
volume_type
string
success
Specifies the ECS system disk type.
SATA is common I/O disk type.
SAS is high I/O disk type.
SSD is ultra-high I/O disk type.
co-p1 is high I/O (performance-optimized I) disk type.
uh-l1 is ultra-high I/O (latency-optimized) disk type.
NOTE is For HANA, HL1, and HL2 ECSs, use co-p1 and uh-l1 disks. For other ECSs, do not use co-p1 or uh-l1 disks.

security_groups
list / elements=string
success
Specifies the security groups of the ECS. If this parameter is left blank, the default security group is bound to the ECS by default.

server_alias
string
success
Specifies the ECS alias.

server_metadata
dictionary
success
Specifies the metadata of ECS to be created.

server_tags
dictionary
success
Specifies the tags of an ECS. When you create ECSs, one ECS supports up to 10 tags.

ssh_key_name
string
success
Specifies the name of the SSH key used for logging in to the ECS.

status
string
success
Specifies the ECS status. Options are ACTIVE, REBOOT, HARD_REBOOT, REBUILD, MIGRATING, BUILD, SHUTOFF, RESIZE, VERIFY_RESIZE, ERROR, and DELETED.

user_data
string
success
Specifies the user data to be injected during the ECS creation process. Text, text files, and gzip files can be injected. The content to be injected must be encoded with base64. The maximum size of the content to be injected (before encoding) is 32 KB. For Linux ECSs, this parameter does not take effect when adminPass is used. Examples are provided as follows 'Linux #! /bin/bash echo user_test &gt;&gt; /home/user.txt Windows rem cmd echo 111 &gt; c:aa.tx'.

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



Authors

  • Huawei (@huaweicloud)