echo "Hello, World!" > index.html nohup python -m SimpleHTTPServer 80 &""" vm = compute.VirtualMachine("server-vm", resource_group_name=resource_group.name, location=resource_group.location, network_interface_ids=[network_iface.id], vm_size="Standard_A0", delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile={ "computer_name": "hostname", "admin_username": username, "admin_password": password, "custom_data": userdata, }, os_profile_linux_config={ "disable_password_authentication": False, }, storage_os_disk={ "create_option": "FromImage", "name": "myosdisk1", }, storage_image_reference={ "publisher": "canonical", "offer": "UbuntuServer", "sku": "16.04-LTS", "version": "latest", }) combined_output = Output.all(vm.id, public_ip.name, public_ip.resource_group_name)
vm = compute.VirtualMachine( "server-vm", name="mirror", resource_group_name=resource_group.name, location=resource_group.location, network_interface_ids=[network_iface.id], vm_size="Standard_DS1_v2", delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile={ "computerName": "hostname", "adminUsername": admin_user, "adminPassword": admin_password }, os_profile_linux_config={ "disablePasswordAuthentication": "true", "sshKeys" : [{ "path" : "/home/dwojciec/.ssh/authorized_keys", "key_data" : ssh_public_key }] }, storage_os_disk={ "create_option": "FromImage", "name": "mirror_disk" }, storage_image_reference={ "publisher": "OpenLogic", "offer": "CentOS", "sku": "7.5", "version": "latest" })
echo "Hello, World!" > index.html nohup python -m SimpleHTTPServer 80 &""" vm = compute.VirtualMachine( "server-vm", resource_group_name=resource_group.name, location=resource_group.location, network_interface_ids=[network_iface.id], vm_size="Standard_A0", delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile=compute.VirtualMachineOsProfileArgs( computer_name="hostname", admin_username=username, admin_password=password, custom_data=userdata, ), os_profile_linux_config=compute.VirtualMachineOsProfileLinuxConfigArgs( disable_password_authentication=False, ), storage_os_disk=compute.VirtualMachineStorageOsDiskArgs( create_option="FromImage", name="myosdisk1", ), storage_image_reference=compute.VirtualMachineStorageImageReferenceArgs( publisher="canonical", offer="UbuntuServer", sku="16.04-LTS", version="latest", )) combined_output = Output.all(vm.id, public_ip.name, public_ip.resource_group_name)
def __init__(self, name: str, args: WebServerArgs, opts: ResourceOptions = None): super().__init__("custom:app:WebServer", name, {}, opts) child_opts = ResourceOptions(parent=self) public_ip = network.PublicIp( "server-ip", resource_group_name=args.resource_group.name, location=args.resource_group.location, allocation_method="Dynamic", opts=child_opts, ) network_iface = network.NetworkInterface( "server-nic", resource_group_name=args.resource_group.name, location=args.resource_group.location, ip_configurations=[ network.NetworkInterfaceIpConfigurationArgs( name="webserveripcfg", subnet_id=args.subnet.id, private_ip_address_allocation="Dynamic", public_ip_address_id=public_ip.id, ) ], opts=child_opts, ) userdata = """#!/bin/bash echo "Hello, World!" > index.html nohup python -m SimpleHTTPServer 80 &""" vm = compute.VirtualMachine( "server-vm", resource_group_name=args.resource_group.name, location=args.resource_group.location, network_interface_ids=[network_iface.id], vm_size="Standard_A0", delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile=compute.VirtualMachineOsProfileArgs( computer_name="hostname", admin_username=args.username, admin_password=args.password, custom_data=userdata, ), os_profile_linux_config=compute.VirtualMachineOsProfileLinuxConfigArgs( disable_password_authentication=False, ), storage_os_disk=compute.VirtualMachineStorageOsDiskArgs( create_option="FromImage", name="myosdisk1", ), storage_image_reference=compute.VirtualMachineStorageImageReferenceArgs( publisher="canonical", offer="UbuntuServer", sku="16.04-LTS", version="latest", ), opts=child_opts, ) # The public IP address is not allocated until the VM is running, so we wait # for that resource to create, and then lookup the IP address again to report # its public IP. combined_output = Output.all( vm.id, public_ip.name, public_ip.resource_group_name ) self.public_ip_addr = combined_output.apply( lambda lst: network.get_public_ip(name=lst[1], resource_group_name=lst[2]).ip_address ) self.register_outputs({})
name='pulumi-nic', resource_group_name=resource_group.name) # Create instance instance = compute.VirtualMachine('machine', location=resource_group.location, name='pulumi-machine', network_interface_ids=[nic.id], os_profile={ "computer_name": "pulumi-machine", "admin_username": "******", "admin_password": password }, os_profile_windows_config={}, resource_group_name=resource_group.name, storage_image_reference={ "publisher": "MicrosoftWindowsServer", "offer": "WindowsServer", "sku": "2016-Datacenter", "version": "latest" }, storage_os_disk={ "create_option": "FromImage", "caching": "ReadWrite", "managed_disk_type": 'Standard_LRS', "name": "pulumi_os_disk" }, vm_size='Standard_F2') # Export the connection string for the storage account pulumi.export('private_ip', nic.private_ip_address)
vm = compute.VirtualMachine('server-vm', resource_group_name=resource_group.name, location=resource_group.location, network_interface_ids=[nic.id], vm_size='Standard_A0', delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile={ 'computer_name': 'hostname', 'admin_username': username, 'admin_password': password, 'custom_data': user_data, }, os_profile_linux_config={ 'disable_password_authentication': False, }, storage_os_disk={ 'create_option': 'FromImage', 'name': 'myosdisk1', }, storage_image_reference={ 'publisher': 'canonical', 'offer': 'UbuntuServer', 'sku': '16.04-LTS', 'version': 'latest', }, boot_diagnostics={ 'enabled': True, 'storage_uri': sa.primary_blob_endpoint, })
vms.append(compute.VirtualMachine( virtual_machine['name'], name=virtual_machine['name'], resource_group_name=resource_group.name, location=resource_group.location, network_interface_ids=[network_ifaces[vm_counter].id], vm_size=vm_size, delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile=os_prof, os_profile_linux_config={ "disable_password_authentication": True, "ssh_keys": [{ "path": "/home/" + admin_username + "/.ssh/authorized_keys", "key_data": ssh_key_data }] }, tags={ "environment": "Pulumi_Demo" }, storage_os_disk={ "create_option": "FromImage", "name": virtual_machine['name'], }, storage_image_reference={ "publisher": virtual_machine['publisher'], "offer": virtual_machine['offer'], "sku": virtual_machine['sku'], "version": virtual_machine['version'], }) )
osdiskname = f"{vm['name']}-osdisk" azvm = compute.VirtualMachine( 'vm', name = f"{vm['name']}", resource_group_name = vm['resource_group_name'], network_interface_ids = [aznic.id], vm_size = vm['size'], storage_os_disk = { "create_option": "FromImage", "name": osdiskname, "managed_disk_type": vm['os_disk_account_type'] }, storage_image_reference = { "publisher": "MicrosoftWindowsServer", "offer": "WindowsServer", "sku": "2016-Datacenter", "version": "latest" }, os_profile = { "admin_username": vm['local_admin'], "admin_password": vm['local_admin_pw'], "computer_name": vm['name'] }, os_profile_windows_config = { "provision_vm_agent": "true", "enable_automatic_upgrades": "true" }, zones = vm['availability_zone'], license_type = "Windows_Server", tags = vm['tags'] )