Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the acf domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Deprecated: Creation of dynamic property ACF::$fields is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields.php on line 138

Deprecated: Creation of dynamic property acf_loop::$loops is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/loop.php on line 28

Deprecated: Creation of dynamic property ACF::$loop is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/loop.php on line 269

Deprecated: Creation of dynamic property ACF::$revisions is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/revisions.php on line 397

Deprecated: Creation of dynamic property acf_validation::$errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/validation.php on line 28

Deprecated: Creation of dynamic property ACF::$validation is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/validation.php on line 214

Deprecated: Creation of dynamic property acf_form_customizer::$preview_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 28

Deprecated: Creation of dynamic property acf_form_customizer::$preview_fields is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 29

Deprecated: Creation of dynamic property acf_form_customizer::$preview_errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 30

Deprecated: Creation of dynamic property ACF::$form_front is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-front.php on line 598

Deprecated: Creation of dynamic property acf_form_widget::$preview_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 34

Deprecated: Creation of dynamic property acf_form_widget::$preview_reference is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 35

Deprecated: Creation of dynamic property acf_form_widget::$preview_errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 36

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the all-in-one-wp-migration domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp_plugin/wp_plugin.php on line 23

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 1539

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 828

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the rocket domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Deprecated: Creation of dynamic property acf_field_oembed::$width is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-oembed.php on line 31

Deprecated: Creation of dynamic property acf_field_oembed::$height is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-oembed.php on line 32

Deprecated: Creation of dynamic property acf_field_google_map::$default_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-google-map.php on line 33

Deprecated: Creation of dynamic property acf_field__group::$have_rows is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-group.php on line 31

Deprecated: Creation of dynamic property acf_field_clone::$cloning is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-clone.php on line 34

Deprecated: Creation of dynamic property acf_field_clone::$have_rows is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-clone.php on line 35

Deprecated: Creation of dynamic property jh_acf_field_table::$settings is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-table-field/class-jh-acf-field-table.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902
{"id":24532,"date":"2017-05-31T09:05:05","date_gmt":"2017-05-31T06:05:05","guid":{"rendered":"https:\/\/upcloud.com\/community\/tutorials\/upcloud-packer-builder"},"modified":"2017-05-31T09:05:05","modified_gmt":"2017-05-31T06:05:05","slug":"upcloud-packer-builder","status":"publish","type":"tutorial","link":"https:\/\/studiogo.tech\/upcloudold\/tutorial\/upcloud-packer-builder\/","title":{"rendered":"How to create custom images using UpCloud Packer builder"},"content":{"rendered":"\n

Packer<\/a> is an easy-to-use automation solution for creating any type of machine image. It embraces modern configuration management by allowing automated software installation and setup within Packer-built images. UpCloud Packer builder<\/a> integrates Packer with our Cloud Servers and makes creating private templates even faster!<\/p>\n\n\n\n

UpCloud Packer builder is a plugin for Packer to simplify template configuration and make deploying custom Cloud Servers quick and easy. In this guide, we\u2019ll show the steps required to install Packer on Linux and how to create your first custom template on UpCloud. Packer is also available for macOS and Windows with their own installation instructions on their download page.<\/p>\n\n\n\n

\n
Test hosting on UpCloud!<\/a><\/div>\n<\/div>\n\n\n\n

Installing Packer<\/h2>\n\n\n\n

Packer can be downloaded for most operating systems as well as installed using common package managers. To install the precompiled binary, you will need to download the appropriate package for your OS. On most popular Linux distributions, you can run the following commands to install Packer using your native package manager.<\/p>\n\n\n\n

# Debian and Ubuntu\ncurl -fsSL https:\/\/apt.releases.hashicorp.com\/gpg | sudo apt-key add -\nsudo apt-add-repository \"deb [arch=amd64] https:\/\/apt.releases.hashicorp.com $(lsb_release -cs) main\"\nsudo apt-get update && sudo apt-get install packer<\/pre>\n\n\n\n
# CentOS\nsudo yum install -y yum-utils\nsudo yum-config-manager --add-repo https:\/\/rpm.releases.hashicorp.com\/RHEL\/hashicorp.repo\nsudo yum -y install packer<\/pre>\n\n\n\n

Afterwards, verify that Packer is working, for example, with the command below.<\/p>\n\n\n\n

packer --version<\/pre>\n\n\n\n
1.7.3<\/pre>\n\n\n\n

The Packer builder leverages the UpCloud Go API to interface with the UpCloud API. You will need to provide a username and password with access rights to the API functions to authenticate. We recommend setting up a new workspace member account with only the API privileges for security purposes. You can do this at your UpCloud Control Panel. Learn more about creating API credentials in our guide for getting started with UpCloud API<\/a>.<\/p>\n\n\n\n

Enter the API user credentials in your terminal with the following two commands. Replace the username<\/tt><\/span> and password<\/tt><\/span> with your user details.<\/p>\n\n\n\n

export PKR_VAR_UPCLOUD_USERNAME=username<\/span>\nexport PKR_VAR_UPCLOUD_PASSWORD=password<\/span><\/pre>\n\n\n\n

You should also save these in your profile file to avoid having to repeat the export command every time you open a new terminal. Simply add the same lines to the ~\/.profile<\/tt> or ~\/.bashrc<\/tt> file.<\/p>\n\n\n\n

Installing Packer is all that you really need to build custom templates on UpCloud. Continue ahead in the next section to get started with configuring your templates.<\/p>\n\n\n\n

Configuring templates<\/h2>\n\n\n\n

Packer uses the Hashicorp configuration language<\/a> (HCL) format for the configuration files to define the template you wish to build. You can find an example configuration on our GitHub repository at \/packer-plugin-upcloud\/examples<\/tt><\/a>.<\/p>\n\n\n\n

To start, you might want to make a new directory for arranging your Packer configurations, for example, ~\/packer<\/tt>.<\/p>\n\n\n\n

mkdir ~\/packer<\/pre>\n\n\n\n

Next create a new template with your favourite editor, for example using the following command.<\/p>\n\n\n\n

nano ~\/packer\/upcloud-template.pkr.hcl<\/pre>\n\n\n\n

Then copy and paste the example template underneath.<\/p>\n\n\n\n

variable \"UPCLOUD_USERNAME\" {\n  type = string\n  default = \"\"\n}\nvariable \"UPCLOUD_PASSWORD\" {\n  type = string\n  sensitive = true\n  default = \"\"\n}\n\npacker {\n    required_plugins {\n        upcloud = {\n            version = \">=v1.0.0\"\n            source = \"github.com\/UpCloudLtd\/upcloud\"\n        }\n    }\n}\n\nsource \"upcloud\" \"example\" {\n  username = \"${var.UPCLOUD_USERNAME}\"\n  password = \"${var.UPCLOUD_PASSWORD}\"\n  zone = \"nl-ams1<\/span>\"\n  storage_name = \"ubuntu server 20.04<\/span>\"\n  template_prefix = \"ubuntu-server\"\n}\n\nbuild {\n  sources = [\"source.upcloud.example\"]\n\n  provisioner \"shell\" {\n    inline = [\n      \"apt-get update\",\n      \"apt-get upgrade -y\",\n      \"echo 'ssh-rsa-key<\/span>' | tee \/root\/.ssh\/authorized_keys\"\n    ]\n  }\n}<\/pre>\n\n\n\n

The basic template is almost ready to deploy. However, you should take a look at the parameters in the source and build<\/tt> segments.<\/p>\n\n\n\n

The username<\/tt> and password<\/tt> are rather self-explanatory and should be the same for every template. Since we already set our actual UpCloud API credentials in the environmental variables, there\u2019s no need to include them in the configuration file. Packer will then find the credentials from your environmental variables at run time and set them in the username and password variables as defined in your configuration.<\/p>\n\n\n\n

The important parts are the target zone<\/tt><\/span> and the source storage-name<\/tt><\/span>. These tell Packer which public template you wish to use as the basis for generating your own and where it should be made available.<\/p>\n\n\n\n

Choose the zone where you wish to deploy cloud servers with the custom template. Note that the custom template is only available in the zone it was created in. If you want to use the custom template to deploy Cloud Servers in multiple zones, you will need to recreate the custom template in each zone.<\/p>\n\n\n\n

The currently available zones are the following:<\/p>\n\n\n\n

Europe<\/p>\n\n\n\n