Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - name: Create Azure VM
- hosts: localhost
- connection: local
- tasks:
- - name: Create resource group
- azure_rm_resourcegroup:
- name: myResourceGroup
- location: local
- - name: Create virtual network
- azure_rm_virtualnetwork:
- resource_group: myResourceGroup
- name: myVnet
- address_prefixes: "10.0.0.0/16"
- - name: Add subnet
- azure_rm_subnet:
- resource_group: myResourceGroup
- name: mySubnet
- address_prefix: "10.0.1.0/24"
- virtual_network: myVnet
- - name: Create public IP address
- azure_rm_publicipaddress:
- resource_group: myResourceGroup
- allocation_method: Static
- name: myPublicIP
- register: output_ip_address
- - name: Dump public IP for VM which will be created
- debug:
- msg: "The public IP is {{ output_ip_address.state.ip_address }}."
- - name: Create Network Security Group that allows SSH
- azure_rm_securitygroup:
- resource_group: myResourceGroup
- name: myNetworkSecurityGroup
- rules:
- - name: SSH
- protocol: Tcp
- destination_port_range: 22
- access: Allow
- priority: 1001
- direction: Inbound
- - name: Create virtual network inteface card
- azure_rm_networkinterface:
- resource_group: myResourceGroup
- name: myNIC
- virtual_network: myVnet
- subnet: mySubnet
- public_ip_name: myPublicIP
- security_group: myNetworkSecurityGroup
- - name: Create VM
- azure_rm_virtualmachine:
- resource_group: myResourceGroup
- name: myVM
- vm_size: Standard_DS1_v2
- admin_username: azureuser
- admin_password: P@ssw0rd000000
- network_interfaces: myNIC
- managed_disk_type: Standard_LRS
- image:
- offer: UbuntuServer
- publisher: Canonical
- sku: 18.04-LTS
- version: latest
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement