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 therun-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
# autoexecutepowershell <your_script> # autoexecutepowershell
Executes the powershell script with initializing the password administrator. The script is launched with the administrator user.
Powershell
# autoexecutepowershellnopasswd <your_script> # autoexecutepowershellnopasswd
Executes the powershell script without initializing the password administrator. The script is launched with the administrator user.
With this command, OUTSCALE does not generate administrator password of the VM. It is therefore not accessible as an administrator. If you want to customize the generation of the administrator password, you can define it in your script.
Vbscript
# autoexecutevbs <your_script> # autoexecutevbs
Executes the vbscript script with initializing the 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. |
-
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.
-
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, anInsufficientCapacity
error is returned. If you do not usestrict
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
orfalse
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-----
-
-
Using Both OUTSCALE Section and Free Section
By default when using the user data, the OUTSCALE section and the free section cannot be used simultaneously. You can use the filter_private_section
filter to use both OUTSCALE and free sections.
To be able to use both OUTSCALE section and free sections use the following filter:
Filter Name | Description | Filter Value | Application |
---|---|---|---|
|
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.
|
|
|
This filter is available for the OUTSCALE API only. It is not compatible with the FCU API. |
In the following example, the 111.33.22.100 public IP is attached and fixed to the VM and the filter on the free section is set to true
:
-----BEGIN OUTSCALE SECTION-----
tags.osc.fcu.eip.auto-attach=111.33.22.100
filter_private_section=true
-----END OUTSCALE SECTION-----
The 111.33.22.100 public IP is attached and fixed to the VM. Then, the tag is removed from the OUTSCALE section and cannot be read in the user data of the VM.
Related Pages
AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.