-
Notifications
You must be signed in to change notification settings - Fork 85
/
ali_instance_test.yml
138 lines (121 loc) · 4.21 KB
/
ali_instance_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
- name: Validate module ali_instance
hosts: localhost
remote_user: root
roles:
- vpc
- vswitch
- security_group
- instance
tasks:
- name: Changed. Modifying name, host name and description when C(present)
alibaba.alicloud.ali_instance:
instance_ids: '{{ instances.ids}}'
name: '{{ name }}-modified'
description: 'Test modify name, host name and description'
host_name: 'modify-host-name'
- name: No Changed. Password and userdata will not be effect when C(present)
alibaba.alicloud.ali_instance:
instance_ids: '{{ instances.ids}}'
password: 'NewTest12345'
user_data: '#!/bin/bash -v \n cd /usr \n mkdir -p alicloud/ansible'
- name: Changed. Modifying password when C(restarted)
alibaba.alicloud.ali_instance:
state: restarted
instance_ids: '{{ instances.ids}}'
password: 'NewTest12345'
force: True
- name: Changed. Modifying userdata when C(stopped)
alibaba.alicloud.ali_instance:
state: stopped
instance_ids: '{{ instances.ids}}'
user_data: '#!/bin/bash -v \n cd /usr \n mkdir -p alicloud/ansible'
- name: Changed. Running the instance and modifying name, host name and description when C(running)
alibaba.alicloud.ali_instance:
state: running
instance_ids: '{{ instances.ids}}'
name: '{{ name }}'
description: '{{instance_description}}'
host_name: 'modify-host-name'
- name: No Changed. There is no any attribute changed
alibaba.alicloud.ali_instance:
instance_ids: '{{ instances.ids}}'
name: '{{ name }}'
description: '{{instance_description}}'
host_name: 'modify-host-name'
password: 'Test12345'
- name: Changed. Adding a tag
alibaba.alicloud.ali_instance:
instance_ids: '{{ instances.ids}}'
tags:
Test1: "add1"
Test2: "add2"
- name: Changed. Modifying a tag
alibaba.alicloud.ali_instance:
instance_ids: '{{ instances.ids}}'
tags:
Test1: "add1"
Test2: "add3"
- name: No Changed. No tags need to be added
alibaba.alicloud.ali_instance:
instance_ids: '{{ instances.ids}}'
tags:
Test1: "add1"
Test2: "add3"
- name: Changed. Removing other tags
alibaba.alicloud.ali_instance:
instance_ids: '{{instances.ids}}'
purge_tags: True
tags:
Test1: "add1"
Test2: "add2"
- name: No Changed. No tags need to be removed
alibaba.alicloud.ali_instance:
instance_ids: '{{instances.ids}}'
purge_tags: True
tags:
Test1: "add1"
Test2: "add2"
# - name: Changed. Modifying instance charge type
# alibaba.alicloud.ali_instance:
# instance_ids: '{{ instances.ids }}'
# instance_charge_type: 'PrePaid'
#
# - name: No Changed. Modifying instance charge type
# alibaba.alicloud.ali_instance:
# instance_ids: '{{ instances.ids }}'
# instance_charge_type: 'PrePaid'
#
# - name: Changed. Modifying instance charge type
# alibaba.alicloud.ali_instance:
# instance_ids: '{{ instances.ids }}'
# instance_charge_type: 'PostPaid'
#
# - name: No Changed. Modifying instance charge type
# alibaba.alicloud.ali_instance:
# instance_ids: '{{ instances.ids }}'
# instance_charge_type: 'PostPaid'
# Delete all of resource
- name: Changed. Deleting instances
alibaba.alicloud.ali_instance:
instance_ids: '{{instances.ids}}'
force: True
state: absent
- name: Changed. Deleting security groups
alibaba.alicloud.ali_security_group:
name: '{{ item.group_name }}'
vpc_id: '{{item.vpc_id}}'
state: absent
with_items: '{{sgs.groups}}'
- name: Changed. Deleting vswitches
alibaba.alicloud.ali_vswitch:
vpc_id: '{{ item.vpc_id}}'
cidr_block: '{{ item.cidr_block}}'
state: absent
with_items: '{{vswitches.vswitches}}'
- name: Changed. Deleting vpcs
alibaba.alicloud.ali_vpc:
name: '{{item.vpc_name}}'
cidr_block: '{{item.cidr_block}}'
state: absent
with_items: '{{vpcs.vpcs}}'