Views: 3393
Last Modified: 25.12.2020

This section describes how to create a BitrixVM image for cloning.

It's useful for developers who set up and clone a BitrixVM virtual appliance minimal configuration. The cloned virtual appliance image is then used to be deployed separately.

Let's overview the setup of two virtual appliance services that are used most frequently:

  • push server
  • memcached server

There are 2 ways of moving BitrixVM virtual appliance: manually, by creating a cloned image for existing virtual appliance with required services included or using an automatic deployment of an image (recommended).

We recommend using automatic image deployment.

Image cloning

BitrixVM virtual appliance can be cloned as follows:

  1. To install the software, create management pool for virtual appliance
  2. Install the required software via menu or scripts
  3. Delete pool settings
  4. Additional system and ssh-keys cleanup
  5. Creating a virtual appliance image

1. Running a management pool for virtual appliance

This step is required to get access to server settings, as well as push-server and memcached setup.

At a clean server, select item 1. Create Management pool of server, it specifically will guide you through the required settings.

Alternatively, execute the following query:

/opt/webdir/bin/wrapper_ansible_conf -a create -H SERVER_NAME -I NET_INTERFACE
where:
-H SERVER_NAME – server name that will be used in settings.
-I NET_INTERFACE – network interface, with IP address used in the pool settings.

This query returns task ID that must be completed to continue:

message
...
Run configuration pool job task_id=common_7874274840
All operations complete

You can trace log file status:

tailf /opt/webdir/temp/common_7874274840/status
...
srv1                       : ok=75   changed=30   unreachable=0    failed=0

When fields unreachable and failed are null, everything is completed successfully to continue to the next stage.


2.1. Configuring push-server

Push-server can be configured using the menu or a command:

/opt/webdir/bin/bx-sites -a push_configure_nodejs -H  SERVER_NAME

Waiting until task completion.

info:bxDaemon:pushserver_2042054462:7097:1594650283::running:::

By default, virtual appliance scenario configures services for using operational IP address, so other appliances joining the pool could use it.

This image is used to copy the virtual appliance, that's why the address most likely, will be different and the specified settings won't be applied. To avoid this, change the server address to localhost, available at any Linux host.

To do it, change the parameter in the file /etc/sysconfig/push-server-multi to:

WS_HOST=127.0.0.1

And re-create push-server configs:

systemctl stop push-server

/etc/init.d/push-server-multi reset

Nginx proxies the queries to push-server based on host name. To ensure it determines everything correctly, where and how to proxy, change entry in /etc/hosts:

127.0.0.1 SERVER_NAME

2.2. Configuring memcached server

Configure memcached server:

/opt/webdir/bin/bx-mc -a create -s SERVER_NAME

At this point, service itself ensures that the address is copied correctly and the access is limited by iptables/firewalld settings.


3. Deleting pool settings

When only a single virtual appliance is in the pool, settings should be deleted to create new ssh-keys and other security settings for the new virtual appliance.

When the pool has several virtual appliances, it's not recommended to save pool settings when copying, because the pool has address update identification mechanisms and the new appliance can take up wizard duties.

Delete the config files and catalogs for ansible:

rm -rf /etc/ansible/{host_vars,group_vars,hosts,ansible-roles}

Or execute an ansible query:

/opt/webdir/bin/wrapper_ansible_conf -a delete_pool

4. Additional cleanup

Delete Udev rules for interfaces:

/bin/rm -f /etc/udev/rules.d/70*

Clean records of MAC-addresses and UUID devices:

/bin/sed -i ‘/^(HWADDR|UUID)=/d’ /etc/sysconfig/network-scripts/ifcfg-eth0

Delete ssh-keys. Upon restart, the new virtual appliance will create new keys:

/bin/rm –f /etc/ssh/*key*

Clean scenario logs:

/bin/rm -fr /opt/webdir/temp/*
/bin/rm -fr /opt/webdir/logs/*

Upon deploying a cloned image on a new location, it's recommended to configure management pool to have an option to continue managing the virtual appliance.

The abovementioned actions can be skipped when the pool remains in the same location, a copy (image) created for backup, and the same virtual appliance will be restored from it, without an address or keys updates.


Automatic image deployment and setup (recommended)

Clean image can be configured automatically. To do it, just add the above-listed commands to your scenario or bash-script:

# creating a pool
/opt/webdir/bin/wrapper_ansible_conf -a create -H SERVER_NAME -I NET_INTERFACE

# configuring push-server
/opt/webdir/bin/bx-sites -a push_configure_nodejs -H  SERVER_NAME

# configuring memcached service
/opt/webdir/bin/bx-mc -a create -s SERVER_NAME

As a result, you get an operational virtual appliance without the need to solve address update issues when copying the template.

Upon each launch, a background job will be executed, with status being traceable, as shown above.





Courses developed by Bitrix24