Configuring a VM with User Data and OUTSCALE Tags

You can add user data to a virtual machine (VM) to more specifically configure it. User data can be of any type of information, like a script or text information. You can also specify tags to give precise instructions about the VM placement or IPs.

User data is data linked to the VM by the user. A VM can access user data at any time but it is taken into account only at creation. However, you can create a script contained in the OMI used to create a VM to require that user data is taken into account at every stop and start. This enables you to modify it, and then stop and start the VM for the modifications to be applied. For more information about how to modify user data, see Modifying a VM Attribute.

To get information about the user data of a VM, type to the following address in the terminal of the VM or in a web browser: 169.254.169.254/latest/user-data.

Adding a Script or Text in User Data

You can add a script or any other text information in the user data of a VM. Your script can contain text variables and can be used to have the VM execute any action you need at boot, for example to automatically download a file from a bucket.

User data must be encoded in Base64, but tools such as Cockpit or AWS CLI can handle the encoding for you. The maximum size for the Base64-encoded user data is 500 kibibytes (KiB).

These user data can be executed every time the VM boots, if the VM contains a script that can do so:

  • In the CREATE VMs dialog box on Cockpit v2 (Creating VMs), or in the user-data attribute of the run-instances AWS CLI command:

    • For Linux VMs, you need to create a script that fetches and executes the user data. For more information, see Creating an Autonomous VM.

    • For Windows VMs, you can type your script within one of the following wrappers to execute it at boot:

      Language Wrapper Description

      Powershell

      # autoexecutepowershellnopasswd
      <your_script>
      # autoexecutepowershellnopasswd

      Executes the powershell script without init password administrator. The script is launched with the administrator user.

      Powershell

      # autoexecutepowershell
      <your_script>
      # autoexecutepowershell

      Executes the powershell script with init password administrator. The script is launched with the administrator user.

      Vbscript

      # autoexecutevbs
      <your_script>
      # autoexecutevbs

      Executes the vbscript script with init password administrator. The script is launched with the administrator user.

      If the boot script finds one of the above wrappers, it saves the script to a VB or PowerShell file in its /userdata and runs these files when the VM starts.

      You can separate the commands in a script using line breaks to run all the commands you want in the Windows PowerShell command prompt.

Adding OUTSCALE Tags in User Data

You can add OUTSCALE tags in user data to give instructions about the placement of your VMs. You can for example place VMs in a same server (also called hypervisor) or cluster (a set of hypervisors) to improve network performance, or place them in different clusters to reduce risks.

You can also add these tags using the classic method. For more information, see Adding or Removing Tags.

  1. If you are using AWS CLI, create a section for all your OUTSCALE tags following this syntax:

    -----BEGIN OUTSCALE SECTION-----
    <tags>
    -----END OUTSCALE SECTION-----

    Insert a carriage return at the end of the code. Otherwise, the last line is not read properly.

  2. Add your tags within this section following the tags.<TAG_NAME>=<TAG_VALUE> format.
    The following tags are available:

    • Tags to specify instructions about the placement of a VM:

      Tag Name Description Tag Value Application

      osc.fcu.repulse_server

      Places VMs with the same tag value on different servers

      Free

      • At VM creation

      • After a stop/start of the VM

      osc.fcu.attract_server

      Places VMs with the same tag value on the same server

      osc.fcu.repulse_cluster

      Places VMs with the same tag value on different Cisco UCS clusters

      osc.fcu.attract_cluster

      Places VMs with the same tag value on the same Cisco UCS cluster

      These tags can be used in strict mode, which means that if the requested placement options are not possible, an InsufficientCapacity error is returned. If you do not use strict mode, the requested placement options are bypassed if they are not possible.

      To define strict mode, add _strict to the tag name (for example, osc.fcu.repulse_server_strict).

      In the following example, VM#1 and VM#2 are placed on the same server, if possible:

      INSTANCE#1 USER DATA
      -----BEGIN OUTSCALE SECTION-----
      tags.osc.fcu.attract_server=front80
      -----END OUTSCALE SECTION-----
      
      INSTANCE#2 USER DATA
      -----BEGIN OUTSCALE SECTION-----
      tags.osc.fcu.attract_server=front80
      -----END OUTSCALE SECTION-----

      In the following example, VM#3 and VM#4 are placed on different servers, and an error occurs if not possible:

      INSTANCE#3 USER DATA
      -----BEGIN OUTSCALE SECTION-----
      tags.osc.fcu.repulse_server_strict=front80
      -----END OUTSCALE SECTION-----
      
      INSTANCE#4 USER DATA
      -----BEGIN OUTSCALE SECTION-----
      tags.osc.fcu.repulse_server_strict=front80
      -----END OUTSCALE SECTION-----
    • Tags to manage IPs associated with a VM:

      Tag Name Description Tag Value Application

      osc.fcu.eip.auto-attach

      Automatically associates a public IP with a VM, and keeps them associated through the stop and start process

      The public IP you want to associate.

      For more information, see About Public IPs > Public IP Association.

      • At VM creation

      • After a stop/start of the VM

      private_only

      Blocks attribution of a public IP to a VM in the public Cloud

      true or false

      In the following example, the 111.33.22.100 public IP is attached and fixed to the VM:

      -----BEGIN OUTSCALE SECTION-----
      tags.osc.fcu.eip.auto-attach=111.33.22.100
      -----END OUTSCALE SECTION-----
    • Tag to be able to use both OUTSCALE section and free section:

      Tag Name Description Tag Value Application

      filter_private_section

      Filters the OUTSCALE tags of the VM so that you can use both a section of OUTSCALE tags and a free section of user data in the same VM.

      If true, all your OUTSCALE tags take effect, but they are not visible when reading the user data of the VM.

      If false or not defined, you cannot use both a section of OUTSCALE tags and a free section of user data.

      true or false

      • At VM creation

      • After a stop/start of the VM

      This tag is available for the OUTSCALE API only. It is not compatible with the FCU API.

Related Pages

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.