-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve (rds): modify rds instance and database #205
Conversation
fd69c54
to
f9a6ca2
Compare
80d0dc6
to
0c7f5f3
Compare
@@ -0,0 +1,251 @@ | |||
#!/usr/bin/python | |||
# Copyright (c) 2017 Alibaba Group Holding Limited. He Guimin <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
时间
DOCUMENTATION = ''' | ||
--- | ||
module: ali_rds_database | ||
version_added: "1.5.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
版本跟其他的一样
description: | ||
- The state of the instance after operating. | ||
default: 'present' | ||
choices: ['present', 'restart', 'absent'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要restart么?
choices: ['present', 'restart', 'absent'] | ||
db_instance_id: | ||
description: | ||
- rds instance id. Required when C(state=present). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加一个alias:instance_id
--- | ||
module: ali_rds_database | ||
version_added: "1.5.0" | ||
short_description: Create, Restart or Terminate an Instance in RDS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个描述跟这个module不符吧
aliases: ['target_id'] | ||
db_names: | ||
description: | ||
- when copy databases between instances, format: {"source instance database name": "target instance database name"}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source instance database name 不就是当前的db name么?
roles: | ||
- vpc | ||
- vswitch | ||
- rds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是得又role的情况下才能这么些,不是所有的用户都有这个
''' | ||
|
||
RETURN = ''' | ||
instance: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
合格return完全跟当前module不符啊,看下其他的return怎么写的
for db in rds.describe_databases(db_instance_id=modules.params['db_instance_id']): | ||
if db.name == name: | ||
match = db | ||
return match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要在文档中说清楚哪些字段来保证module的幂等
@@ -0,0 +1,219 @@ | |||
#!/usr/bin/python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面的modudle都先按照上面的review改,改完后在review
db_description: create for ansible test | ||
state: present | ||
|
||
- name: Get the existing db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看下别的module的example是怎么写的
6b0507b
to
1b7f943
Compare
- database name. It must be 2 to 64 characters in length.It must start with a lowercase letter and end with a | ||
lowercase letter or digit. It can contain lowercase letters, digits, underscores (_), and hyphens (-). | ||
The database name must be unique whithin the instance. | ||
For more information about invalid characters, see Forbidden keywords table(https://www.alibabacloud.com/help/doc-detail/26317.htm?spm=a2c63.p38356.879954.8.617de6d58lT07x#reference-pwh-14n-12b). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
链接中问号及问号后面的那长串不要
description: | ||
- database character name. MySQL or MariaDB (utf8 | gbk | latin1 | utf8mb4). | ||
SQL Server (Chinese_PRC_CI_AS | Chinese_PRC_CS_AS | SQL_Latin1_General_CP1_CI_AS | SQL_Latin1_General_CP1_CS_AS | Chinese_PRC_BIN). | ||
see more (https://www.alibabacloud.com/help/doc-detail/26258.htm?spm=a2c63.l28256.b99.795.310413c7998oJs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个也一样
description: | ||
- The ID of the destination instance, which must differ from the ID of the source instance. | ||
aliases: ['target_instance_id'] | ||
db_names: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果只有一个元素,直接写成target_db_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
拷贝一个实例数据库到另一个实例,需要两个参数的,原数据库名字和拷贝之后的命名
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对啊,原数据库名为 db_name; 拷贝后的叫做 target_db_name
returned: always | ||
type: string | ||
sample: rm-uf6wjk5xxxxxxx | ||
dbname: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥return中就连起来了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
它返回的参数叫DBName, footmark转换之后就连在一起了
changed: [localhost] => {
"changed": true,
"database": {
"accounts": {
"account_privilege_info": []
},
"character_set_name": "utf8",
"dbdescription": "create for ansible test",
"dbinstance_id": "rm-2zef503eq1vkmop04",
"dbname": "ansible_test",
"dbstatus": "Running",
"description": "create for ansible test",
"engine": "MySQL",
"id": "rm-2zef503eq1vkmop04",
"name": "ansible_test",
"status": "Running"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
分开
EXAMPLES = ''' | ||
- name: Get the existing database with name prefix | ||
ali_rds_database_info: | ||
name_prefix: ansible_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
字符串得要引号吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试过了,不加引号也没问题
''' | ||
|
||
RETURN = ''' | ||
database: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info 返回的是一个list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
database->databases
1ea83e1
to
4ef5d81
Compare
description: | ||
- The ID of the destination instance, which must differ from the ID of the source instance. | ||
aliases: ['target_instance_id'] | ||
db_names: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对啊,原数据库名为 db_name; 拷贝后的叫做 target_db_name
returned: always | ||
type: string | ||
sample: rm-uf6wjk5xxxxxxx | ||
dbname: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
分开
''' | ||
|
||
RETURN = ''' | ||
database: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
database->databases
options: | ||
state: | ||
description: | ||
- The state of the instance after operating. | ||
choices: ['present', 'restart', 'absent'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state:
description:
- If I(state=present), instance will be created.
- If I(state=present) and instance exists, it will be updated.
- If I(state=absent), instance will be removed.
- If I(state=restart), instance will be restarted.
default: present
choices: ['present', 'restart', 'absent']
以后所有的state都这样写,说清楚每个state分别是干什么的
- Type of payment. Postpaid: postpaid instance; Prepaid: prepaid instance. Required when C(state=present). | ||
choices: [ "Postpaid", "Prepaid" ] | ||
- The billing method of the instance.Required when C(state=present). | ||
choices: ["Postpaid", "Prepaid"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所有的计费类型统一为 PostPaid
和 PrePaid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个也没改啊
- Port of public net work. | ||
private_port: | ||
- The prefix of the target connection address. Only the prefix of CurrentConnectionString can be modified. | ||
is_readonly: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只读实例单独抽象为一个module吧
description: | ||
- Automatic renewal period. Required when C(auto_renew='True') | ||
choices: [1, 2, 3, 6, 12] | ||
- Instance id, the unique identifier of the instance. Required when C(state in ["present", "absent", "restart"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用 instance name来保证幂等吧
80518bf
to
f1a81d5
Compare
sync_user_privilege: | ||
description: | ||
- Indicates whether to copy users and permissions. | ||
choices: ['YES', 'NO'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用一个bool来代替 yes和no
version_added: "2.9.2" | ||
short_description: Create, delete or copy an database in Alibaba Cloud RDS. | ||
description: | ||
- Create, delete, copy or modify description for database in RDS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以后在所有的module的description中都显示的说明当前这个module的唯一标识符有哪几个字段决定,比如这个database的增加这么一句:
- An unique ali_rds_database module is co-determined by parameters db_instance_id and db_name.
- database name. It must be 2 to 64 characters in length.It must start with a lowercase letter and end with a | ||
lowercase letter or digit. It can contain lowercase letters, digits, underscores (_), and hyphens (-). | ||
The database name must be unique whithin the instance. this will specify unique database in one instance. | ||
For more information about invalid characters, see Forbidden keywords table U(https://www.alibabacloud.com/help/doc-detail/26317.htm). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一个module的唯一性除了最上面说明外,在每个参数中的描述中也在再说明一次,比如db_name:
- This is used in combination with C(db_instance_id) to determine if the database already exists.
db_instance_id:
- This is used in combination with C(db_name) to determine if the database already exists.
returned: always | ||
type: string | ||
sample: MySQL | ||
id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个ID去掉吧
DOCUMENTATION = ''' | ||
--- | ||
module: ali_rds_database_info | ||
version_added: "2.9.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个版本号以后统一写成2.9 吧
returned: always | ||
type: string | ||
sample: MySQL | ||
id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id 去掉吧
SQL Server (2008r2 | 2012 | 2012_ent_ha | 2012_std_ha | 2012_web | 2016_ent_ha | 2016_std_ha | 2016_web | 2017_ent) | ||
PostgreSQL (9.4 | 10.0) | ||
PPAS (9.3 | 10.0) | ||
MariaDB (10.3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种最好分行显示:
- MySQL (5.5 | 5.6 | 5.7 | 8.0)
- SQL Server (2008r2 | 2012 | 2012_ent_ha | 2012_std_ha | 2012_web | 2016_ent_ha | 2016_std_ha | 2016_web | 2017_ent)
- PostgreSQL (9.4 | 10.0)
- PPAS (9.3 | 10.0)
- MariaDB (10.3)
connection_mode: | ||
description: The access mode of the instance | ||
returned: always | ||
type: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
返回参数中没有分配的connection string啊。这个出参至少要跟入参对齐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改用了另一个接口,返回了更全的参数,已经补充
description: The access mode of the instance | ||
returned: always | ||
type: string | ||
sample: Standard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info中的出参要跟module中的出参保持一直
short_description: Create, delete or copy an database in Alibaba Cloud RDS. | ||
description: | ||
- Create, delete, copy or modify description for database in RDS. | ||
An unique ali_rds_database module is co-determined by parameters db_instance_id and db_name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前面的 “-” 呢?
如果没有 “-”,会跟在上面那行,如果有,会另起一行
lowercase letter or digit. It can contain lowercase letters, digits, underscores (_), and hyphens (-). | ||
this will specify unique database in one instance. | ||
For more information about invalid characters, see Forbidden keywords table U(https://www.alibabacloud.com/help/doc-detail/26317.htm). | ||
This is used in combination with C(db_instance_id) to determine if the database already exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个也一样,加一个 “-”
- Target instance database name. | ||
backup_id: | ||
description: | ||
- The ID of the backup set on the source instance. When you copy databases based on the backup set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最后的句号呢
db_name: ansible_test | ||
character_set_name: utf8 | ||
db_description: create for ansible test | ||
state: present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example中最好不要出现test的字眼
db_instance_id: | ||
description: | ||
- The ID of the instance. | ||
aliases: ["instance_id"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个应该得是required的吧,没有实例id怎么查database啊
choices: ["Internet", "Intranet"] | ||
aliases: ['db_instance_net_type'] | ||
description: | ||
db_instance_description: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成 db_instance_name, alias是 name 和 description
- Type of payment. Postpaid: postpaid instance; Prepaid: prepaid instance. Required when C(state=present). | ||
choices: [ "Postpaid", "Prepaid" ] | ||
- The billing method of the instance.Required when C(state=present). | ||
choices: ["Postpaid", "Prepaid"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个也没改啊
choices: [1~9,12,24,36] | ||
default: 1 | ||
- The prepayment period of the instance. | ||
choices: ['Year', 'Month'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
统一都采用 Month,如果计费周期大于9,就将其转换为年
choices: ["Performance", "Safty"] | ||
- The access mode of the instance. | ||
choices: ["Standard", "Safe"] | ||
instance_network_type: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance_network_type 可以去掉,如果指定了vswitchid,就是 vpc,否则就是classic
page_size: | ||
- The intranet IP address of the instance. It must be within the IP address range provided by the switch. | ||
By default, the system automatically assigns an IP address based on the VPCId and VSwitchId. | ||
db_instance_id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db_instance_id 是用来干嘛的
790995f
to
dbb73cd
Compare
description: | ||
- Create, restart, modify or terminate rds instances. | ||
- Create, Restart, Delete and Modify connection_string, spec for RDS Instance. | ||
- An unique ali_rds_instance module is determined by parameters db_instance_description(instance name). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是改称 db_instance_name 了么
description: | ||
- Type of payment. Postpaid: postpaid instance; Prepaid: prepaid instance. Required when C(state=present). | ||
choices: [ "Postpaid", "Prepaid" ] | ||
- The billing method of the instance.Required when C(state=present). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
句号后如果还有语句,要空一格
choices: [1~9,12,24,36] | ||
default: 1 | ||
default: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
每一行最后不要留对于的空格
if ins.name == name: | ||
res = ins | ||
if res: | ||
res = rds.describe_db_instance_attribute(DBInstanceId=res.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥还要再查一遍
db_instance_name=dict(type='str', aliases=['description', 'name'], required=True), | ||
security_ip_list=dict(type='str', aliases=['security_ips']), | ||
pay_type=dict(type='str', choices=["PostPaid", "PrePaid"]), | ||
period=dict(type='str', choice=['1', '2', '3', '4', '5', '6', '7', '8', '9', '12', '24', '36'], default='1'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个period的类型应该是 int把
47c975c
to
2ec2fd2
Compare
No description provided.