Packer
Outscale
@outscale
Use Packer to create Outscale OMIs.
- Partner
Updated 11 months ago
- GitHub(opens in new tab)
Outscale BSU Volume
Type: outscale-bsuvolume
Artifact BuilderId: oapi.outscale.bsuvolume
The outscale-bsuvolume
Packer builder is able to create Ouscale Block Stogate Unit
volumes which are prepopulated with filesystems or data.
This builder builds BSU volumes by launching an Outscale VM from a source OMI, provisioning that running machine, and then destroying the source machine, keeping the volumes intact.
This is all done in your own Outscale account. The builder will create temporary key pairs, security group rules, etc. that provide it temporary access to the instance while the image is being created.
The builder does not manage BSU Volumes. Once it creates volumes and stores it in your account, it is up to you to use, delete, etc. the volumes.
Note: Temporary resources are, by default, all created with the
prefix packer
. This can be useful if you want to restrict the security groups
and key pairs Packer is able to operate on.
Configuration Reference
There are many configuration options available for the builder. They are segmented below into two categories: required and optional parameters. Within each category, the available configuration keys are alphabetized.
In addition to the options listed here, a communicator can be configured for this builder.
Required:
access_key
(string) - The access key used to communicate with OUTSCALE. Learn how to set thisvm_type
(string) - The Outscale VM type to use while building the OMI, such ast2.small
.region
(string) - The name of the region, such asus-east-1
, in which to launch the Outscale VM to create the OMI.secret_key
(string) - The secret key used to communicate with Outscale. Learn how to set thissource_omi
(string) - The initial OMI used as a base for the newly created machine.source_omi_filter
may be used instead to populate this automatically.
Optional:
ebs_volumes
(array of block device mappings) - Add the block device mappings to the OMI. The block device mappings allow for keys:device_name
(string) - The device name exposed to the VM (for example,/dev/sdh
orxvdh
). Required for every device in the block device mapping.delete_on_vm_deletion
(boolean) - Indicates whether the BSU volume is deleted on instance termination.iops
(number) - The number of I/O operations per second (IOPS) that the volume supports. See the documentation on IOPs for more information.no_device
(boolean) - Suppresses the specified device included in the block device mapping of the OMI.snapshot_id
(string) - The ID of the snapshotvirtual_name
(string) - The virtual device name. See the documentation on Block Device Mapping for more informationvolume_size
(number) - The size of the volume, in GiB. Required if not specifying asnapshot_id
volume_type
(string) - The volume type.gp2
for General Purpose (SSD) volumes,io1
for Provisioned IOPS (SSD) volumes, andstandard
for Magnetic volumestags
(map) - Tags to apply to the volume. These are retained after the builder completes. This is a template engine, see Build template data for more information.
associate_public_ip_address
(boolean) - If using a non-default Net, public IP addresses are not provided by default. If this is toggled, your new VM will get a Public IP.subregion_name
(string) - Destination subregion to launch VM in. Leave this empty to allow Outscale to auto-assign.custom_endpoint_oapi
(string) - This option is useful if you use a cloud provider whose API is compatible with Outscale OAPI. Specify another endpoint like thisoutscale.com/oapi/latest
.disable_stop_vm
(boolean) - Packer normally stops the build VM after all provisioners have run. For Windows VMs, it is sometimes desirable to run Sysprep which will stop the VM for you. If this is set totrue
, Packer will not stop the VM but will assume that you will send the stop signal yourself through your final provisioner. You can do this with a windows-shell provisioner.Note that Packer will still wait for the VM to be stopped, and failing to send the stop signal yourself, when you have set this flag to
true
, will cause a timeout.bsu_optimized
(boolean) - If true, the VM is created with optimized BSU I/O.insecure_skip_tls_verify
(boolean) - This allows skipping TLS verification of the OAPI endpoint. The default isfalse
.run_tags
(object of key/value strings) - Tags to apply to the instance that is launched to create the OMI. These tags are not applied to the resulting OMI unless they're duplicated intags
. This is a template engine, see Build template data for more information.security_group_id
(string) - The ID (not the name) of the security group to assign to the VM. By default this is not set and Packer will automatically create a new temporary security group to allow SSH access. Note that if this is specified, you must be sure the security group allows access to thessh_port
given below.security_group_ids
(array of strings) - A list of security groups as described above. Note that if this is specified, you must omit thesecurity_group_id
.shutdown_behavior
(string) - Automatically terminate instances on shutdown in case Packer exits ungracefully. Possible values arestop
andterminate
. Defaults tostop
.shutdown_behavior
(string) - Automatically terminate VMs on shutdown in case Packer exits ungracefully. Possible values are "stop" and "terminate", default isstop
.source_omi_filter
(object) - Filters used to populate thesource_omi
field.filters
(map of strings) - filters used to select asource_omi
.owners
(array of strings) - Filters the images by their owner. You may specify one or more Outscale account IDs, "self" (which will use the account whose credentials you are using to run Packer), or an Outscale owner alias. This option is required for security reasons.Example:
{ "source_omi_filter": { "filters": { "virtualization-type": "hvm", "image-name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*", "root-device-type": "ebs" }, "owners": ["099720109477"] } }
This selects an Ubuntu 16.04 HVM BSU OMIS from Canonical. NOTE: This will fail unless exactly one OMIS is returned. In the above example,
most_recent
will cause this to succeed by selecting the newest image.
ssh_keypair_name
(string) - If specified, this is the key that will be used for SSH with the machine. The key must match a key pair name loaded up into Outscale. By default, this is blank, and Packer will generate a temporary keypair unlessssh_password
is used.ssh_private_key_file
orssh_agent_auth
must be specified whenssh_keypair_name
is utilized.ssh_interface
(string) - One ofpublic_ip
,private_ip
,public_dns
, orprivate_dns
. If set, either the public IP address, private IP address, public DNS name or private DNS name will used as the host for SSH. The default behaviour if inside a Net is to use the public IP address if available, otherwise the private IP address will be used. If not in a Net the public DNS name will be used. Also works for WinRM.Where Packer is configured for an outbound proxy but WinRM traffic should be direct,
ssh_interface
must be set toprivate_dns
and<region>.compute.internal
included in theNO_PROXY
environment variable.subnet_id
(string) - If using Net, the ID of the subnet, such assubnet-12345def
, where Packer will launch the VM. This field is required if you are using an non-default Net.temporary_key_pair_name
(string) - The name of the temporary key pair to generate. By default, Packer generates a name that looks likepacker_<UUID>
, where <UUID> is a 36 character unique identifier.temporary_security_group_source_cidr
(string) - An IPv4 CIDR block to be authorized access to the VM, when packer is creating a temporary security group. The default is0.0.0.0/0
(i.e., allow any IPv4 source). This is only used whensecurity_group_id
orsecurity_group_ids
is not specified.user_data
(string) - User data to apply when launching the VM. Note that you need to be careful about escaping characters due to the templates being JSON. It is often more convenient to useuser_data_file
, instead. Packer will not automatically wait for a user script to finish before shutting down the VM this must be handled in a provisioner.user_data_file
(string) - Path to a file that will be used for the user data when launching the VM.net_id
(string) - If launching into a Net subnet, Packer needs the Net ID in order to create a temporary security group within the Net. Requiressubnet_id
to be set. If this field is left blank, Packer will try to get the Net ID from thesubnet_id
.net_filter
(object) - Filters used to populate thenet_id
field. Example:{ "net_filter": { "filters": { "is-default": "false", "ip-range": "/24" } } }
This selects the Net with a IPv4 CIDR block of
/24
. NOTE: This will fail unless exactly one Net is returned.filters
(map of strings) - filters used to select avpc_id
. NOTE: This will fail unless exactly one Net is returned.net_id
take precedence over this.
windows_password_timeout
(string) - The timeout for waiting for a Windows password for Windows VMs. Defaults to 20 minutes. Example value:10m
Basic Example
{
"builders": [
{
"type": "outscale-bsuvolume",
"region": "eu-west-2",
"vm_type": "t2.micro",
"source_omi": "ami-65efcc11",
"ssh_username": "outscale",
"ebs_volumes": [
{
"volume_type": "gp2",
"device_name": "/dev/xvdf",
"delete_on_vm_deletion": false,
"tags": {
"zpool": "data",
"Name": "Data1"
},
"volume_size": 10
},
{
"volume_type": "gp2",
"device_name": "/dev/xvdg",
"tags": {
"zpool": "data",
"Name": "Data2"
},
"delete_on_vm_deletion": false,
"volume_size": 10
},
{
"volume_size": 10,
"tags": {
"Name": "Data3",
"zpool": "data"
},
"delete_on_vm_deletion": false,
"device_name": "/dev/xvdh",
"volume_type": "gp2"
}
]
}
]
}
Note: Packer can also read the access key and secret access key from environmental variables. See the configuration reference in the section above for more information on what environmental variables Packer will look for.
Further information on locating OMI's IDs and their relationship to VM types and regions can be found in the Outscale Documentation reference.
Accessing the Instance to Debug
If you need to access the instance to debug for some reason, run the builder
with the -debug
flag. In debug mode, the Amazon builder will save the private
key in the current directory and will output the DNS or IP information as well.
You can use this information to access the instance as it is running.
Build template data
In configuration directives marked as a template engine above, the following variables are available:
BuildRegion
- The region (for exampleeu-west-2
) where Packer is building the OMI.SourceOMI
- The source OMI ID (for exampleami-a2412fcd
) used to build the OMI.SourceOMIName
- The source OMI Name (for exampleubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306
) used to build the OMI.SourceOMITags
- The source OMI Tags, as amap[string]string
object.
Note: Packer uses pre-built OMIs as the source for building images. These source OMIs may include volumes that are not flagged to be destroyed on termination of the instance building the new image. In addition to those volumes created by this builder, any volumes in the source OMI which are not marked for deletion on termination will remain in your account.