Recipes in VMmanager

From ISPWiki
Jump to: navigation, search
Hierarchy: VMmanager KVM -> OS templates section
VMmanager Cloud -> OS templates section

Recipes are scripts running on a virtual machine after OS deployment from template. They help prepare a virtual machine for specific operations: install packages, edit configuration files, etc.

A recipe can be selected in the VM creation form.

In the "Cluster settings/Recipes" section you can choose a default recipe that will be executed after every OS installation and re-installation.

Recipes are supported only on Linux virtual machines. Recipe execution timeout is 3 hours.

Creating and managing recipes

Navigate to the "Cluster settings" --> "Recipes" section. By default, this section contains ISPsystem repository and its recipes.

«Receipe management»
  • Update — update data in repository;
  • Add — add a new local recipe. The recipes will be located in the local repository on the master-server;
  • Edit — edit recipe;
  • Properties — edit recipe permissions;
  • Delete — delete recipe;
  • Repositories — manage recipe repositories:
    • Add - add new repository:
      • Repositories - repository name;
      • URL to the recipe archive file;
    • Edit - edit repository URL;
    • Delete - delete the repository.

Please note: ISPsystem repository and its recipes cannot be deleted.

When you choose a recipe in the cluster policy settings, the control panel will save its internal name rather than its id. Several recipes can have similar internal names, but different tags. You can create two recipes with similar names, but different tags. During OS installation the first recipe compatible with a template, which names match each other, will be selected. Therefore, you can set different recipes for different operating systems.

Recipe file structure

A block with comments containing recipe metadata is added into the recipe body:

# metadata_begin
# recipe: hello_world
# tags: unix
# revision: 1
# description_ru:
# description_en:
# metadata_end

Metadata are used by the control panel for

  • displaying a recipe in a list of recipes;
  • choosing an appropriate recipe according to cluster policy settings.

The metadata block begins with the key phrase metadata_begin, and ends with the key phrase metadata_end. The following metadata can be located between them:

  • recipe: - recipe internal name. Several recipes can have similar internal names, the control panel doesn't check them. An internal name must be specified.
  • tags: - number of tags comma separated. They allow to check a recipe and OS template. OS templates have tags. A recipe is compatible with a template if any recipe tag matches any of template tags.
  • revision: - recipe version. This version will be shown in the corresponding column in the control panel.
  • description_XX: - brief description of a recipe on a certain language. It is displayed in the list of recipes and on the VM creation/re-installation forms.

Macros

In recipes you can use macros that will be changed into corresponding values before the recipe is executed.

VMmanager KVM, Cloud macros:

  • ($HOSTNAME) - domain name of a virtual machine
  • ($TIMEZONE) - server time zone. Host time zone is set by default, but you can change it in the panel's configuration file.

VMmanager OVZ macors:

  • ($TIMEZONE) - server time zone. Host time zone is set by default, but you can change it in the panel's configuration file.

Recipe execution methods

VMmanager KVM: Connect via SSH to the VM with already installed operating system. The recipe file is copied into a temporary directory on the virtual machine and started with root permissions.

VMmanager OVZ: a recipe is passed to the cluster node's control panel, and saved in a temporary file on the disk The recipe is started with the vzctl utility.

vzctl runscript CTID filename

where CTID is a container id, filename - a temporary file with a recipe saved on cluster node.

Recipes that can be added by users

Add the following option into the configuration file to allow users to use recipes:

Option UserRecipes

By default, the configuration file is located in the /usr/local/mgr5/etc directory. Restart the panel to apply the changes:

/usr/local/mgr5/sbin/mgrctl -m vmmgr exit

Once completed, users will be able to create recipes and use them during OS re-installation on a virtual machine in the "Management/Recipes" section.