79 lines
2.6 KiB
YAML
79 lines
2.6 KiB
YAML
---
|
|
# tasks file for azure-createwindowsvm
|
|
# - name: Create public IP address
|
|
# azure_rm_publicipaddress:
|
|
# resource_group: "{{RG_name}}"
|
|
# allocation_method: Static
|
|
# name: "{{hostname}}-pip"
|
|
# register: output_ip_address
|
|
|
|
# - name: Output public IP
|
|
# debug:
|
|
# msg: "The public IP is {{ output_ip_address.state.ip_address }}"
|
|
|
|
|
|
- name: Get facts for one resource group
|
|
azure_rm_resourcegroup_info:
|
|
name: "{{RG_name}}"
|
|
register: rginfo
|
|
- name: Create a network interface
|
|
azure_rm_networkinterface:
|
|
name: "{{hostname}}-nic"
|
|
resource_group: "{{RG_name}}"
|
|
location: westeurope
|
|
virtual_network: "/subscriptions/a7f4215b-c8f8-45ac-8fdd-062c940b02f6/resourceGroups/rg-network-glb-02/providers/Microsoft.Network/virtualNetworks/vnet-awe-glb-02"
|
|
subnet_name: "{{subnetname}}"
|
|
enable_accelerated_networking: True
|
|
security_group: "/subscriptions/a7f4215b-c8f8-45ac-8fdd-062c940b02f6/resourceGroups/rg-network-glb-02/providers/Microsoft.Network/networkSecurityGroups/nsg-glb-02-green"
|
|
ip_configurations:
|
|
- name: default
|
|
# public_ip_address_name: "{{hostname}}-pip"
|
|
primary: True
|
|
register: new_nic
|
|
|
|
- name: Get private IP of NIC
|
|
azure_rm_networkinterface_info:
|
|
resource_group: "{{RG_name}}"
|
|
name: "{{hostname}}-nic"
|
|
register: nic_info
|
|
|
|
- name: Display private IP of NIC
|
|
debug:
|
|
var: "nic_info.networkinterfaces[0].ip_configurations[0].private_ip_address"
|
|
- name: Get facts by name
|
|
azure_rm_virtualmachine_info:
|
|
resource_group: "{{RG_name}}"
|
|
name: "{{hostname}}"
|
|
register: vmexist
|
|
|
|
- name: Create VM
|
|
azure_rm_virtualmachine:
|
|
resource_group: "{{RG_name}}"
|
|
name: "{{hostname}}"
|
|
vm_size: "{{vmsize}}"
|
|
admin_username: ApeAdmin
|
|
admin_password: "{{ password }}"
|
|
network_interfaces: "{{hostname}}-nic"
|
|
os_type: Linux
|
|
boot_diagnostics:
|
|
enabled: false
|
|
managed_disk_type: "Premium_LRS"
|
|
os_disk_name: "{{hostname}}-osdisk"
|
|
os_disk_size_gb: 128
|
|
image:
|
|
offer: "{{lin_offer}}"
|
|
publisher: Canonical
|
|
sku: "{{lin_sku}}"
|
|
version: latest
|
|
tags:
|
|
Dexcare: "{{tag_dexcare}}"
|
|
ApplicationITContact: "{{tag_ApplicationITContact}}"
|
|
DexMach_Protection: "ManagedByOther"
|
|
Schedule: "{{tag_Schedule}}"
|
|
ServiceHours: "{{tag_ServiceHours}}"
|
|
Criticality: "{{tag_Criticality}}"
|
|
UpdateSchedule: "{{tag_UpdateSchedule}}"
|
|
TeamSpecialist: "{{tag_TeamSpecialist}}"
|
|
no_log: false
|
|
when: vmexist is failed
|
|
|