|
|
@ -20,113 +20,143 @@
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
ANSIBLE_METADATA = {
|
|
|
|
|
|
|
|
'metadata_version': '1.1',
|
|
|
|
'status': ['preview'],
|
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'community'}
|
|
|
|
'supported_by': 'community'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
|
|
|
---
|
|
|
|
module: ali_instance
|
|
|
|
module: ali_instance
|
|
|
|
version_added: "2.8"
|
|
|
|
version_added: '2.8'
|
|
|
|
short_description: Create, Start, Stop, Restart or Terminate an Instance in ECS. Add or Remove Instance to/from a Security Group.
|
|
|
|
short_description: Create, start, stop, restart or terminate an instance in ECS, add or remove an instance to/from a security group
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Create, start, stop, restart, modify or terminate ecs instances.
|
|
|
|
- Create, start, stop, restart, modify or terminate ecs instances.
|
|
|
|
- Add or remove ecs instances to/from security group.
|
|
|
|
- Add or remove ecs instances to/from security group.
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
state:
|
|
|
|
state:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The state of the instance after operating.
|
|
|
|
- The state of the instance after operating.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
default: 'present'
|
|
|
|
default: 'present'
|
|
|
|
choices: [ 'present', 'running', 'stopped', 'restarted', 'absent' ]
|
|
|
|
choices: ['absent', 'present', 'restarted', 'running', 'stopped']
|
|
|
|
availability_zone:
|
|
|
|
availability_zone:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Aliyun availability zone ID in which to launch the instance.
|
|
|
|
- Aliyun availability zone ID in which to launch the instance.
|
|
|
|
If it is not specified, it will be allocated by system automatically.
|
|
|
|
- If it is not specified, it will be allocated by system automatically.
|
|
|
|
aliases: ['alicloud_zone']
|
|
|
|
aliases: ['alicloud_zone']
|
|
|
|
|
|
|
|
type: str
|
|
|
|
image_id:
|
|
|
|
image_id:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Image ID used to launch instances. Required when C(state=present) and creating new ECS instances.
|
|
|
|
- Image ID used to launch instances.
|
|
|
|
aliases: [ 'image' ]
|
|
|
|
- Required when I(state=present) and creating new ECS instances.
|
|
|
|
|
|
|
|
aliases: ['image']
|
|
|
|
|
|
|
|
type: str
|
|
|
|
instance_type:
|
|
|
|
instance_type:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Instance type used to launch instances. Required when C(state=present) and creating new ECS instances.
|
|
|
|
- Instance type used to launch instances.
|
|
|
|
|
|
|
|
- Required when I(state=present) and creating new ECS instances.
|
|
|
|
aliases: ['type']
|
|
|
|
aliases: ['type']
|
|
|
|
|
|
|
|
type: str
|
|
|
|
security_groups:
|
|
|
|
security_groups:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A list of security group IDs.
|
|
|
|
- A list of security group IDs.
|
|
|
|
|
|
|
|
type: list
|
|
|
|
vswitch_id:
|
|
|
|
vswitch_id:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The subnet ID in which to launch the instances (VPC).
|
|
|
|
- The subnet ID in which to launch the instances (VPC).
|
|
|
|
aliases: ['subnet_id']
|
|
|
|
aliases: ['subnet_id']
|
|
|
|
|
|
|
|
type: str
|
|
|
|
instance_name:
|
|
|
|
instance_name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The name of ECS instance, which is a string of 2 to 128 Chinese or English characters. It must begin with an
|
|
|
|
- The name of ECS instance, which is a string of 2 to 128 Chinese or English characters.
|
|
|
|
uppercase/lowercase letter or a Chinese character and can contain numerals, ".", "_" or "-".
|
|
|
|
- It must begin with an uppercase/lowercase letter or a Chinese character and
|
|
|
|
It cannot begin with http:// or https://.
|
|
|
|
can contain numerals, ".", "_" or "-". It cannot begin with http:// or https://.
|
|
|
|
aliases: ['name']
|
|
|
|
aliases: ['name']
|
|
|
|
|
|
|
|
type: str
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The description of ECS instance, which is a string of 2 to 256 characters. It cannot begin with http:// or https://.
|
|
|
|
- The description of ECS instance, which is a string of 2 to 256 characters.
|
|
|
|
|
|
|
|
- It cannot begin with http:// or https://.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
internet_charge_type:
|
|
|
|
internet_charge_type:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Internet charge type of ECS instance.
|
|
|
|
- Internet charge type of ECS instance.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
default: 'PayByBandwidth'
|
|
|
|
default: 'PayByBandwidth'
|
|
|
|
choices: ['PayByBandwidth', 'PayByTraffic']
|
|
|
|
choices: ['PayByBandwidth', 'PayByTraffic']
|
|
|
|
max_bandwidth_in:
|
|
|
|
max_bandwidth_in:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Maximum incoming bandwidth from the public network, measured in Mbps (Megabits per second).
|
|
|
|
- Maximum incoming bandwidth from the public network,
|
|
|
|
|
|
|
|
measured in Mbps (Megabits per second).
|
|
|
|
default: 200
|
|
|
|
default: 200
|
|
|
|
|
|
|
|
type: int
|
|
|
|
max_bandwidth_out:
|
|
|
|
max_bandwidth_out:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Maximum outgoing bandwidth to the public network, measured in Mbps (Megabits per second).
|
|
|
|
- Maximum outgoing bandwidth to the public network, measured in Mbps (Megabits per second).
|
|
|
|
|
|
|
|
type: int
|
|
|
|
default: 0
|
|
|
|
default: 0
|
|
|
|
host_name:
|
|
|
|
host_name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Instance host name.
|
|
|
|
- Instance host name.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
password:
|
|
|
|
password:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The password to login instance. After rebooting instances, modified password will take effect.
|
|
|
|
- The password to login instance.
|
|
|
|
|
|
|
|
- After rebooting instances, modified password will take effect.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
system_disk_category:
|
|
|
|
system_disk_category:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Category of the system disk.
|
|
|
|
- Category of the system disk.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
default: 'cloud_efficiency'
|
|
|
|
default: 'cloud_efficiency'
|
|
|
|
choices: ['cloud_efficiency', 'cloud_ssd']
|
|
|
|
choices: ['cloud_efficiency', 'cloud_ssd']
|
|
|
|
system_disk_size:
|
|
|
|
system_disk_size:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Size of the system disk, in GB. The valid values are 40~500.
|
|
|
|
- Size of the system disk, in GB. The valid values are 40~500.
|
|
|
|
|
|
|
|
type: int
|
|
|
|
default: 40
|
|
|
|
default: 40
|
|
|
|
system_disk_name:
|
|
|
|
system_disk_name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Name of the system disk.
|
|
|
|
- Name of the system disk.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
system_disk_description:
|
|
|
|
system_disk_description:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Description of the system disk.
|
|
|
|
- Description of the system disk.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
count:
|
|
|
|
count:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The number of the new instance. An integer value which indicates how many instances that match I(count_tag)
|
|
|
|
- The number of the new instance.
|
|
|
|
should be running. Instances are either created or terminated based on this value.
|
|
|
|
- Indicates how many instances that match I(count_tag) should be running.
|
|
|
|
|
|
|
|
- Instances are either created or terminated based on this value.
|
|
|
|
|
|
|
|
type: int
|
|
|
|
default: 1
|
|
|
|
default: 1
|
|
|
|
count_tag:
|
|
|
|
count_tag:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- I(count) determines how many instances based on a specific tag criteria should be present.
|
|
|
|
- Determines how many instances based on a specific tag criteria should be present.
|
|
|
|
This can be expressed in multiple ways and is shown in the EXAMPLES section.
|
|
|
|
- This can be expressed in multiple ways and is shown in the EXAMPLES section.
|
|
|
|
The specified count_tag must already exist or be passed in as the I(instance_tags) option.
|
|
|
|
- The specified count_tag must already exist or be passed in as the I(instance_tags) option.
|
|
|
|
If it is not specified, it will be replaced by I(instance_name).
|
|
|
|
- If it is not specified, it will be replaced by I(instance_name).
|
|
|
|
|
|
|
|
type: str
|
|
|
|
allocate_public_ip:
|
|
|
|
allocate_public_ip:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Whether allocate a public ip for the new instance.
|
|
|
|
- Whether allocate a public ip for the new instance.
|
|
|
|
default: False
|
|
|
|
default: False
|
|
|
|
aliases: [ 'assign_public_ip' ]
|
|
|
|
aliases: ['assign_public_ip']
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
instance_charge_type:
|
|
|
|
instance_charge_type:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The charge type of the instance.
|
|
|
|
- The charge type of the instance.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
choices: ['PrePaid', 'PostPaid']
|
|
|
|
choices: ['PrePaid', 'PostPaid']
|
|
|
|
default: 'PostPaid'
|
|
|
|
default: 'PostPaid'
|
|
|
|
period:
|
|
|
|
period:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The charge duration of the instance, in month. Required when C(instance_charge_type=PrePaid).
|
|
|
|
- The charge duration of the instance, in month.
|
|
|
|
|
|
|
|
- Required when I(instance_charge_type=PrePaid).
|
|
|
|
- The valid value are [1-9, 12, 24, 36].
|
|
|
|
- The valid value are [1-9, 12, 24, 36].
|
|
|
|
|
|
|
|
type: int
|
|
|
|
default: 1
|
|
|
|
default: 1
|
|
|
|
auto_renew:
|
|
|
|
auto_renew:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -135,12 +165,15 @@ options:
|
|
|
|
default: False
|
|
|
|
default: False
|
|
|
|
auto_renew_period:
|
|
|
|
auto_renew_period:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The duration of the automatic renew the charge of the instance. Required when C(auto_renew=True).
|
|
|
|
- The duration of the automatic renew the charge of the instance.
|
|
|
|
|
|
|
|
- Required when I(auto_renew=True).
|
|
|
|
|
|
|
|
type: int
|
|
|
|
choices: [1, 2, 3, 6, 12]
|
|
|
|
choices: [1, 2, 3, 6, 12]
|
|
|
|
instance_ids:
|
|
|
|
instance_ids:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A list of instance ids. It is required when need to operate existing instances.
|
|
|
|
- A list of instance ids. It is required when need to operate existing instances.
|
|
|
|
If it is specified, I(count) will lose efficacy.
|
|
|
|
- If it is specified, I(count) will lose efficacy.
|
|
|
|
|
|
|
|
type: list
|
|
|
|
force:
|
|
|
|
force:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Whether the current operation needs to be execute forcibly.
|
|
|
|
- Whether the current operation needs to be execute forcibly.
|
|
|
@ -148,11 +181,14 @@ options:
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
instance_tags:
|
|
|
|
instance_tags:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A hash/dictionaries of instance tags, to add to the new instance or for starting/stopping instance by tag. C({"key":"value"})
|
|
|
|
- A hash/dictionaries of instance tags, to add to the new instance or
|
|
|
|
aliases: ["tags"]
|
|
|
|
for starting/stopping instance by tag (C({"key":"value"})).
|
|
|
|
|
|
|
|
aliases: ['tags']
|
|
|
|
|
|
|
|
type: dict
|
|
|
|
key_name:
|
|
|
|
key_name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The name of key pair which is used to access ECS instance in SSH.
|
|
|
|
- The name of key pair which is used to access ECS instance in SSH.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
aliases: ['keypair']
|
|
|
|
aliases: ['keypair']
|
|
|
|
user_data:
|
|
|
|
user_data:
|
|
|
@ -160,16 +196,17 @@ options:
|
|
|
|
- User-defined data to customize the startup behaviors of an ECS instance and to pass data into an ECS instance.
|
|
|
|
- User-defined data to customize the startup behaviors of an ECS instance and to pass data into an ECS instance.
|
|
|
|
It only will take effect when launching the new ECS instances.
|
|
|
|
It only will take effect when launching the new ECS instances.
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
type: str
|
|
|
|
author:
|
|
|
|
author:
|
|
|
|
- "He Guimin (@xiaozhu36)"
|
|
|
|
- "He Guimin (@xiaozhu36)"
|
|
|
|
requirements:
|
|
|
|
requirements:
|
|
|
|
- "python >= 2.6"
|
|
|
|
- "python >= 2.6"
|
|
|
|
- "footmark >= 1.1.16"
|
|
|
|
- "footmark >= 1.1.16"
|
|
|
|
extends_documentation_fragment:
|
|
|
|
extends_documentation_fragment:
|
|
|
|
- alicloud
|
|
|
|
- alicloud
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = r'''
|
|
|
|
# basic provisioning example vpc network
|
|
|
|
# basic provisioning example vpc network
|
|
|
|
- name: basic provisioning example
|
|
|
|
- name: basic provisioning example
|
|
|
|
hosts: localhost
|
|
|
|
hosts: localhost
|
|
|
@ -259,9 +296,9 @@ EXAMPLES = '''
|
|
|
|
security_groups: '{{ security_groups }}'
|
|
|
|
security_groups: '{{ security_groups }}'
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
RETURN = r'''
|
|
|
|
instances:
|
|
|
|
instances:
|
|
|
|
description: List of ECS instances
|
|
|
|
description: List of ECS instances.
|
|
|
|
returned: always
|
|
|
|
returned: always
|
|
|
|
type: complex
|
|
|
|
type: complex
|
|
|
|
contains:
|
|
|
|
contains:
|
|
|
@ -456,7 +493,7 @@ instances:
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
sample: 10.0.0.1
|
|
|
|
sample: 10.0.0.1
|
|
|
|
public_ip_address:
|
|
|
|
public_ip_address:
|
|
|
|
description: The public IPv4 address assigned to the instance
|
|
|
|
description: The public IPv4 address assigned to the instance.
|
|
|
|
returned: always
|
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
sample: 43.0.0.1
|
|
|
|
sample: 43.0.0.1
|
|
|
@ -502,7 +539,7 @@ instances:
|
|
|
|
type: dict
|
|
|
|
type: dict
|
|
|
|
sample: vpc-0011223344
|
|
|
|
sample: vpc-0011223344
|
|
|
|
ids:
|
|
|
|
ids:
|
|
|
|
description: List of ECS instance IDs
|
|
|
|
description: List of ECS instance IDs.
|
|
|
|
returned: always
|
|
|
|
returned: always
|
|
|
|
type: list
|
|
|
|
type: list
|
|
|
|
sample: [i-12345er, i-3245fs]
|
|
|
|
sample: [i-12345er, i-3245fs]
|
|
|
|