Table of contents
1.
✨Introduction
2.
✨Existing A2HA to Automate HA
2.1.
🧬Prerequisites
2.2.
🧬Migration 
3.
✨Chef Backend to Automate HA
3.1.
🧬Backup the Existing Chef Backend Data 
3.2.
🧬Restore Backed Up Data to Chef Automate HA
3.3.
🧬In place Migration (Chef Backend to Automate HA)
4.
✨CHEF - Backup & Restore 
4.1.
🧬Backup
4.2.
🧬Restore 
5.
Frequently Asked Questions
5.1.
Are the chef servers free?
5.2.
What do the Chef, server, and client do?
5.3.
What is a migrate server?
5.4.
Which backup options are available?
6.
Conclusion
Last Updated: Mar 27, 2024
Medium

CHEF - MIGRATION

Author Kumar Saurav
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

✨Introduction

Chef is an automation company. Since 2008, their self-titled product, Chef Infra, has brought programmers and system administrators together. Over time, the definition of automation has evolved. Chef now provides a complete automation solution that moves infrastructure and apps from development to production.

MIGRATION

✨Existing A2HA to Automate HA

This page describes transferring current A2HA data to the recently installed Chef Automate HA. The following steps involve in this migration:

🧬Prerequisites

  • Possibility of mounting the file system to Automate HA that mounts to A2HA Cluster for backup purposes.
     
  • A2HA is set up to do backups on network drives that mount (for instance, at /mnt/automate backup).
AUTOMATE HA

🧬Migration 

1. Use any automated instance in the A2HA Cluster to run the following commands.

sudo chef-automate backup create
sudo chef-automate bootstrap bundle create bootstrap.abb

 

  • The backup at the mount file system will be taken by the first command. The file /hab/a2 deploy workspace/a2ha.rb on the bastion node contains the mount path.
     
  • The second command will create the bootstrap bundle, which we need to copy all of the frontend nodes of the Automate HA cluster.
     
  • Please save the backup ID once the backup has been adequately completed. Examples include 20210622065515.
     
  • Run the command on the Automate node to acquire the backup id (chef-automate backup list) if you want to use a previously produced backup.
     
Backup             		State       	Age
20180508201548    completed  8 minutes old
20180508201643    completed  8 minutes old
20180508201952    completed  4 minutes old


2. The file system must be separated from the previous A2HA cluster.

3. If you haven't already, set up the backup in the Automate HA cluster.

4. You can obtain the backup mount path from Step 3.

5. In the Automate HA Cluster, stop all services at the frontend nodes.

  • Run the command below on each Automate and Chef Infrastructure Server node.
     
sudo chef-automate stop


6. We require the airgap bundle to conduct the restoration operation. Obtain the Automate HA airgap bundle from the Automate instance's /var/tmp/ directory. For instance, frontend-4.x.y.aib.

  • If the airgap bundle is missing from /var/tmp, we can copy it to the Automate node from the Bastion node.
     
  • To obtain the configured settings, issue the command at the Chef-Automate node of the Automate HA cluster.
     
sudo chef-automate config show > current_config.toml 

 
7. The applied config should now include the OpenSearch credentials.

  • Add the following configuration to current_config.toml  if using Chef Managed Open search (without any changes).
     
  • Add the following configuration to current_config.toml if utilizing AWS Managed services (change this with your actual credentials)

✨Chef Backend to Automate HA

This page outlines moving the data from the current Chef Backend to the recently installed Chef Automate HA. There are two steps in this migration:

knife-ec-backup can be used to back up the data from an existing Chef Backend.

Use knife-ec-restore to restore the backed-up data to the Chef Automate HA environment that was just deployed.

Using the knife-ec-backup tool, create a backup, then transfer the backup folder to the Chef Server that has just been set up. Utilize the same utility to restore later. All recipes, users, data bags, policies, and organizations are migrated during the backup.

Using an intermediate, editable text format, the knife-ec-backup program backs up and restores the data in an Enterprise Chef Server installation. It utilizes the same supporting libraries as the knife download and knife upload commands. It offers remedies for several Server API flaws as well as unsupported items by the tools. The intention is to deprecate the tool by enhancing knife download, knife upload, and the Chef Infra Server API.

BACKEND TO AUTOMATE HA

🧬Backup the Existing Chef Backend Data 

1. To install Habitat, use the command below: 

Curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh \ | sudo bash


2. To install the habitat package for knife-ec-backup, run the command below.

hab pkg install chef/knife-ec-backup


3. To analyze the stale node, data, etc., run the command below to create a knife tidy server report. Within this command:

  • The user's name is pivotal.
     
  • The location of the user's pem file is specified by the path of pivotal.
     
  • Before a node is regarded as out-of-date, a maximum of days have passed since the last check. node-threshold  NUM DAYS.
     
hab pkg exec chef/knife-ec-backup knife tidy server report --node-threshold 60 -s <chef server URL> -u <pivotal> -k <path of pivotal>


The example is as follows:

hab pkg exec chef/knife-ec-backup knife tidy server report --node-threshold 60 -s https://chef.io -u pivotal -k /etc/opscode/pivotal.pem


4. Run the command below to start a backup of your Chef Server data. Within this command: 

  • To manage user passwords and ensure user-specific association groups are unique, with-user-sql is necessary.
     
  • When a customer has users with several pem keys linked to their user or client, —with-key-sql is used to handle the situation. The chef-server API currently dumps only the default key. Users occasionally create and assign extra keys to grant access to additional users while remaining able to lock out those users later without robbing everyone.
     
hab pkg exec chef/knife-ec-backup knife ec backup backup_$(date '+%Y%m%d%H%M%s') --webui-key /etc/opscode/webui_priv.pem -s <chef server


The example is as follows:

hab pkg exec chef/knife-ec-backup knife ec backup backup_$(date '+%Y%m%d%H%M%s') --webui-key /etc/opscode/webui_priv.pem -s https://chef.io`.

 

  • Run the command shown below to remove unnecessary data from reports. This step is optional.
     
hab pkg exec chef/knife-ec-backup knife tidy server clean --backup-path /path/to/an-ec-backup


5. Run the command below to copy the backup directory to the Automate HA Chef Server.

scp -i /path/to/key backup\_$(date '+%Y%m%d%H%M%s') 

🧬Restore Backed Up Data to Chef Automate HA

  • To install the habitat package for knife-ec-backup, run the command below.
     
 hab pkg install chef/knife-ec-backup

 

  • To restore the backup, use the command below.
     
hab pkg exec chef/knife-ec-backup knife ec restore /home/centos/backup\_2021061013191623331154 -yes --concurrency 1 --webui-key /hab/svc/automate-cs-oc-erchef/data/webui\_priv.pem --purge -c /hab/pkgs/chef/chef-server-ctl/*/*/omnibus-ctl/spec/fixtures/pivotal.rb

🧬In place Migration (Chef Backend to Automate HA)

In this scenario, the customer will switch from chef-backend (5 machines) to Automate HA in place. Meaning that Automate HA will only be installed on the five computers that are now running Chef-backend. It will need to add one more bastion node to handle the Automate HA deployment on the chef backend infrastructure.

✨CHEF - Backup & Restore 

🧬Backup

Using Chef Automate, a fresh backup may be created. You can create it by running the backup command from a Chef Automate front-end node. The backup command appears as follows: 

chef-automate backup create

BACKUP AND RESTORE

🧬Restore 

This section includes instructions for restoring data that was backed up by Chef Automate High Availability (HA) using the External File System (EFS) and an Amazon Web Services (AWS) S3 bucket.

While the backup is active, all data is restored throughout the restore operation. When the restoration operation is finished, the ongoing backup process also ceases. To better understand the complete procedure, let's use the following example:

  • Automate the creation of UserA's Token1 API token.
     
  • Create a backup with ID 20220708044530 as the backup.
     
  • Create UserB as a new user and a Token2 API token for them.
     
  • Think of a situation where you need to retrieve data from an automation cluster still in use.

Frequently Asked Questions

Are the chef servers free?

There is just one Chef Server that is completely open source and free. Customers of Enterprise Chef and users of Open Source Chef profit from this in different ways: Chef Server 12 includes Enterprise Chef's multi-tenancy and role-based access management functionality.

What do the Chef, server, and client do?

The Chef Server serves as the central node and workstation. All of the recipe metadata, cookbooks, and cookbooks are stored here. The workstation delivers the cookbook to the server using a knife. The nodes connect to the server using the Chef client.

What is a migrate server?

The process of copying or moving important data from one server to another and configuring the new server to take the place of the old is known as server migration.

Which backup options are available?

There are three types of backups: full, differential, and incremental.

Conclusion

In this article, we have extensively discussed CHEF - Migration. We have also addressed the Existing A2HA to Automate HA in CHEF - Migration. Under Existing A2HA to Automate HA, we have discussed Prerequisite and Migration. Then we have seen the Chef Backend to Automate HA in CHEF - Migration. Under this topic, we discussed subtopics like Backup of the Existing Chef Backend Data, Restoring Backed Up Data to Chef Automate HA, and In place Migration. Then finally, we have seen Backup & Restore in CHEF - Migration.

Refer to the following links for more information:
 

You can refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Live masterclass