Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. - name: Create Azure VM
  2. hosts: localhost
  3. connection: local
  4. tasks:
  5. - name: Create resource group
  6. azure_rm_resourcegroup:
  7. name: myResourceGroup
  8. location: local
  9. - name: Create virtual network
  10. azure_rm_virtualnetwork:
  11. resource_group: myResourceGroup
  12. name: myVnet
  13. address_prefixes: "10.0.0.0/16"
  14. - name: Add subnet
  15. azure_rm_subnet:
  16. resource_group: myResourceGroup
  17. name: mySubnet
  18. address_prefix: "10.0.1.0/24"
  19. virtual_network: myVnet
  20. - name: Create public IP address
  21. azure_rm_publicipaddress:
  22. resource_group: myResourceGroup
  23. allocation_method: Static
  24. name: myPublicIP
  25. register: output_ip_address
  26. - name: Dump public IP for VM which will be created
  27. debug:
  28. msg: "The public IP is {{ output_ip_address.state.ip_address }}."
  29. - name: Create Network Security Group that allows SSH
  30. azure_rm_securitygroup:
  31. resource_group: myResourceGroup
  32. name: myNetworkSecurityGroup
  33. rules:
  34. - name: SSH
  35. protocol: Tcp
  36. destination_port_range: 22
  37. access: Allow
  38. priority: 1001
  39. direction: Inbound
  40. - name: Create virtual network inteface card
  41. azure_rm_networkinterface:
  42. resource_group: myResourceGroup
  43. name: myNIC
  44. virtual_network: myVnet
  45. subnet: mySubnet
  46. public_ip_name: myPublicIP
  47. security_group: myNetworkSecurityGroup
  48. - name: Create VM
  49. azure_rm_virtualmachine:
  50. resource_group: myResourceGroup
  51. name: myVM
  52. vm_size: Standard_DS1_v2
  53. admin_username: azureuser
  54. admin_password: P@ssw0rd000000
  55. network_interfaces: myNIC
  56. managed_disk_type: Standard_LRS
  57. image:
  58. offer: UbuntuServer
  59. publisher: Canonical
  60. sku: 18.04-LTS
  61. version: latest
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement