-
Notifications
You must be signed in to change notification settings - Fork 0
/
caws1.yml
66 lines (62 loc) · 2.78 KB
/
caws1.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
---
- name: AZURE CREATE W2012 R2 SERVER
connection: local
gather_facts: no
# hosts: all
hosts: localhost
vars:
my_resource_group: MyResourceGroup
# my_vm_name: anspocw2012
# my_vn_name: poc-vn
# my_sn_name: poc-sn
winrm_enable_script: SQBuAHYAbwBrAGUALQBFAHgAcAByAGUAcwBzAGkAbwBuACAALQBDAG8AbQBtAGEAbgBkACAAKAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkAcwB0AGUAbQAuAE4AZQB0AC4AVwBlAGIAQwBsAGkAZQBuAHQAKQAuAEQAbwB3AG4AbABvAGEAZABTAHQAcgBpAG4AZwAoACcAaAB0AHQAcABzADoALwAvAHIAYQB3AC4AZwBpAHQAaAB1AGIAdQBzAGUAcgBjAG8AbgB0AGUAbgB0AC4AYwBvAG0ALwBhAG4AcwBpAGIAbABlAC8AYQBuAHMAaQBiAGwAZQAvAGQAZQB2AGUAbAAvAGUAeABhAG0AcABsAGUAcwAvAHMAYwByAGkAcAB0AHMALwBDAG8AbgBmAGkAZwB1AHIAZQBSAGUAbQBvAHQAaQBuAGcARgBvAHIAQQBuAHMAaQBiAGwAZQAuAHAAcwAxACcAKQApADsAIABFAG4AYQBiAGwAZQAtAFcAUwBNAGEAbgBDAHIAZQBkAFMAUwBQACAALQBSAG8AbABlACAAUwBlAHIAdgBlAHIAIAAtAEYAbwByAGMAZQA=
tasks:
- name: CREATE AZURE STORAGE ACCOUNT
azure_rm_storageaccount:
subscription_id: "{{ my_subscription_id }}"
client_id: "{{ my_client_id }}"
secret: "{{ my_secret }}"
tenant: "{{ my_tenant }}"
name: '{{ my_vm_name }}'
resource_group: "{{ my_resource_group }}"
account_type: Standard_LRS
- name: PROVSION VIRTUAL HOST
azure_rm_virtualmachine:
subscription_id: "{{ my_subscription_id }}"
client_id: "{{ my_client_id }}"
secret: "{{ my_secret }}"
tenant: "{{ my_tenant }}"
admin_username: richard
admin_password: "{{ my_admin_password }}"
os_type: Windows
image:
offer: WindowsServer
publisher: MicrosoftWindowsServer
sku: 2012-R2-Datacenter
version: latest
name: "{{ my_vm_name }}"
resource_group: "{{ my_resource_group }}"
state: present
vm_size: Standard_D1
storage_account_name: "{{ my_vm_name }}"
virtual_network_name: "{{ my_vm_name }}-VN"
subnet_name: "{{ my_vm_name }}-SN"
- name: CREATE AZURE VM EXTENSION TO ENABLE HTTPS WINRM LISTENER
azure_rm_virtualmachine_extension:
subscription_id: "{{ my_subscription_id }}"
client_id: "{{ my_client_id }}"
secret: "{{ my_secret }}"
tenant: "{{ my_tenant }}"
name: winrm-extension
resource_group: "{{ my_resource_group }}"
virtual_machine_name: "{{ my_vm_name }}"
publisher: Microsoft.Compute
virtual_machine_extension_type: CustomScriptExtension
type_handler_version: 1.9
settings: '{"commandToExecute": "powershell.exe -ExecutionPolicy ByPass -EncodedCommand {{winrm_enable_script}}"}'
auto_upgrade_minor_version: true
- name: WAIT FOR WINRM TO GO ONLINE
wait_for:
port: 5986
host: '{{azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties.publicIPAddress.properties.ipAddress}}'
timeout: 600