-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.yml
211 lines (183 loc) · 9.38 KB
/
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<<<<<<< HEAD
- name: Create an AKS instance (check mode)
azure_rm_aks:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
location: eastus
dns_prefix: "aks{{ resource_group | hash('md5') | truncate(10, True, '') }}"
kubernetes_version: 1.11.5
service_principal:
client_id: "{{ lookup('env', 'AZURE_CLIENT_ID') }}"
client_secret: "{{ lookup('env', 'AZURE_SECRET') }}"
linux_profile:
admin_username: azureuser
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
agent_pool_profiles:
- name: default
count: 1
vm_size: Standard_DS1_v2
check_mode: yes
- name: Check there is no AKS created
azure_rm_aks_facts:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
register: fact
- name: Check there is no AKS created
assert:
that:
- "fact.aks | length == 0"
- name: Create an AKS instance
azure_rm_aks:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
location: eastus
dns_prefix: "aks{{ resource_group | hash('md5') | truncate(10, True, '') }}"
kubernetes_version: 1.11.5
service_principal:
client_id: "{{ lookup('env', 'AZURE_CLIENT_ID') }}"
client_secret: "{{ lookup('env', 'AZURE_SECRET') }}"
linux_profile:
admin_username: azureuser
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
agent_pool_profiles:
- name: default
count: 1
vm_size: Standard_DS1_v2
enable_rbac: yes
register: output
- name: Assert the AKS instance is well created
assert:
that:
- output.changed
- output.provisioning_state == 'Succeeded'
- name: Get AKS fact
azure_rm_aks_facts:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
register: fact
- name: Assert fact returns the created one
assert:
that:
- "fact.aks | length == 1"
- fact.aks[0].id == output.id
- name: Create an AKS instance (idempotent)
azure_rm_aks:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
location: eastus
dns_prefix: "aks{{ resource_group | hash('md5') | truncate(10, True, '') }}"
kubernetes_version: 1.11.5
service_principal:
client_id: "{{ lookup('env', 'AZURE_CLIENT_ID') }}"
linux_profile:
admin_username: azureuser
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
agent_pool_profiles:
- name: default
count: 1
vm_size: Standard_DS1_v2
enable_rbac: yes
register: output
- name: Assert idempotent
assert:
that:
- not output.changed
- name: Upgrade the AKS instance
azure_rm_aks:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
location: eastus
dns_prefix: "aks{{ resource_group | hash('md5') | truncate(10, True, '') }}"
kubernetes_version: 1.11.5
service_principal:
client_id: "{{ lookup('env', 'AZURE_CLIENT_ID') }}"
linux_profile:
admin_username: azureuser
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
agent_pool_profiles:
- name: default
count: 1
vm_size: Standard_DS1_v2
register: output
- name: Assert the AKS instance is upgraded
assert:
that:
- output.changed
- output.kubernetes_version == '1.11.5'
- name: Scale the AKS instance agent count from 1 to 2
azure_rm_aks:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
location: eastus
dns_prefix: "aks{{ resource_group | hash('md5') | truncate(10, True, '') }}"
kubernetes_version: 1.11.5
service_principal:
client_id: "{{ lookup('env', 'AZURE_CLIENT_ID') }}"
linux_profile:
admin_username: azureuser
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
agent_pool_profiles:
- name: default
count: 2
vm_size: Standard_DS1_v2
register: output
- name: Assert the AKS instance is well scaled
assert:
that:
- output.changed
- output.agent_pool_profiles[0].count == 2
- name: Delete the AKS instance
azure_rm_aks:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
state: absent
register: output
- name: Assert the AKS instance is well deleted
assert:
that:
- output.changed
- name: Delete the AKS instance (idempotent)
azure_rm_aks:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
state: absent
register: output
- name: Assert idempotent
assert:
that:
- not output.changed
- name: Get AKS fact
azure_rm_aks_facts:
name: "aks{{ resource_group | hash('md5') | truncate(7, True, '') }}"
resource_group: "{{ resource_group }}"
register: fact
- name: Assert fact returns empty
assert:
that:
- "fact.aks | length == 0"
=======
fred@fred-Virtual-Machine:~/task$ ansible-playbook azure_rm_networkinterface_location01.yml
PLAY [For Azure learn] ****************************************************************************************
TASK [Gathering Facts] ****************************************************************************************
ok: [127.0.0.1]
TASK [create resource group] **********************************************************************************
changed: [127.0.0.1]
TASK [create virtual network] *********************************************************************************
changed: [127.0.0.1]
TASK [Add subnet] *********************************************************************************************
changed: [127.0.0.1]
TASK [create public ip] ***************************************************************************************
changed: [127.0.0.1]
TASK [Create security group that allows SSH] ******************************************************************
changed: [127.0.0.1]
TASK [Create NIC] *********************************************************************************************
[DEPRECATION WARNING]: Setting ip_configuration flatten is deprecated and will be removed. Using
ip_configurations list to define the ip configuration. This feature will be removed in version 2.9.
Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [127.0.0.1]
TASK [Create virtual machine] *********************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Error creating or updating virtual machine vm-klltest02 - Azure Error: SkuNotAvailable\nMessage: The requested size for resource '/subscriptions/2085065b-00f8-4cba-9675-ba15f4d4ab66/resourceGroups/klltest-rg11/providers/Microsoft.Compute/virtualMachines/vm-klltest02' is currently not available in location 'eastus2' zones '' for subscription '2085065b-00f8-4cba-9675-ba15f4d4ab66'. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details."}
to retry, use: --limit @/home/fred/task/azure_rm_networkinterface_location01.retry
PLAY RECAP ****************************************************************************************************
127.0.0.1 : ok=7 changed=6 unreachable=0 failed=1
>>>>>>> 8b4199fa8f051ead640963dd9fc4044ce7309074