Create a Virtual Machine in Azure using Ansible

ansible 6 years, 4 months ago
- name: Create Azure VM hosts: localhost connection: local tasks: - name: Create virtual network azure_rm_virtualnetwork: resource_group: testvm name: myVnet address_prefixes: "10.0.0.0/16" - name: Add subnet azure_rm_subnet: resource_group: testvm name: mySubnet address_prefix: "10.0.1.0/24" virtual_network: myVnet - name: Create public IP address azure_rm_publicipaddress: resource_group: testvm allocation_method: Static name: myPublicIP - name: Create Network Security Group that allows SSH azure_rm_securitygroup: resource_group: testvm 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: testvm name: myNIC virtual_network: myVnet subnet: mySubnet public_ip_name: myPublicIP security_group: myNetworkSecurityGroup - name: Create VM azure_rm_virtualmachine: resource_group: testvm name: myVM vm_size: Standard_A2_v2 admin_username: admin_password: ssh_password_enabled: false ssh_public_keys: - path: /home/azureuser/.ssh/authorized_keys #copy and paste your ssh public key in "key_data" variable key_data: " " network_interfaces: myNIC image: offer: CentOS publisher: OpenLogic sku: '7.3' version: latest
2368
Posted By