Overview

Openstack is deployed for multiple purposes — such as teaching or training, exploring certain features, developing or enhancing Openstack projects, integrating Openstack with other systems, running test or production workloads etc.

We often need to deploy and redeploy Openstack in the same physical server for multiple purposes including:

1. Upgrades

2. Problems with deployment

3. Perfecting configurations

4. Changes in the hypervisor

5. Trying other configuration options for fine tuning

6. Openstack deployment training

The challenge with redeployment is that we need to trace back all the packages that were installed as part of Openstack and uninstall all of them. It’s a tedious and cumbersome process. The other option is to reinstall the operating system but that’s time consuming. The best way is to restore the physical server to previous its state using the Snapper tool. This tutorial outlines the procedure for installing Snapper, creating a Snapshot of the physical server similar to a virtual image, deploying Openstack and restoring the physical server to previous state of deployment.

Openstack

OpenStack is a leading open-source software platform for cloud computing, mostly deployed as an infrastructure-as-a-service (IaaS). The software platform consists of interrelated components that control diverse, multi-vendor hardware pools of processing, storage and networking resources throughout a data center.

Snapper

Snapper is a Linux command ­line tool to create and manage snapshots of your filesystems. It allows users to create read­-only snapshots of a physical machines which can be used to restore the state of the server during any disaster-type situation.

Steps for Deploying Openstack with Snapper and restoring to original state

This block diagram outlines the various layer involved in the setup.

Prerequisites:

File system should be a BTRFS file system.

OS: Ubuntu14.04,16.04

Snapper Version 0.1.8

Resource requirement 4GB RAM 20GB HDD

Note: Snapper is fully supported in the Open SUSE platform

Step-1 : Install Snapper

Install Snapper using the below command

apt-get install snapper -y

Step-2 : Prepare script for creating Config and Mount point

Create below script with name snapperconfigandmountpoint.sh.

#Snapper with btrfs filesystem in ubuntu 14.04 ARGS=$(getopt -o a:b -l "configname:,mountpoint:" -- "[email protected]"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--mountpoint) shift; if [ -n "$1" ]; then mountpoint=$1; shift; fi ;; --) shift; break; ;; esac done #creating a config file echo $configname echo $mountpoint snapper -c $configname create-config $mountpoint snapper list-configs

Step-3 : Run script for creating Config and Mount point

Run script using the below command. Use the same configname and mount point till the end.

bash snapperconfigandmountpoint.sh –configname –mountpoint

Eg:

bash snapperconfigandmountpoint.sh –config name snapconfig –mountpoint /

Where,

snapperconfigandmountpoint.sh – script name

Snapconfig- config name

/- mount point

Step-4 : Prepare script for creating snapshot

Create below script with name Snapshotcreation.sh

ARGS=$(getopt -o a:b -l "configname:,snapshotname:" -- "[email protected]"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--snapshotname) shift; if [ -n "$1" ]; then snapshotname=$1; shift; fi ;; --) shift; break; ;; esac done echo $configname echo $snapshotname snapper --config $configname create --description "$snapshotname " snapper --config $configname list

Step-5 : Run script to create a Snapshot using Snapper

Run script using the below command

bash snapshotcreation.sh –configname –snapshotname

Eg :

bash snapshotcreation.sh –configname snapconfig –snapshotname snap1

Where,

Snapshotcreation.sh – script name

Snapconfig- config name

snap1- snapshot name

The execution with create a snapshot and list the created snapshots. Create the snapshot name of your choice but remember to provide the same config name used earlier.

Step-6 : Deploy Openstack

Deploy Openstack Mitaka by following the instruction available at: https://docs.openstack.org/mitaka/install-guide-ubuntu/

Step-7 : Prepare a Script to restore the snapshot

Create below script with name Restore.sh for restoring the physical server to older version.

ARGS=$(getopt -o a:b:c -l "configname:,state_to_revert:,state_to_modify:," -- "[email protected]"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--state_to_revert) shift; if [ -n "$1" ]; then state_to_revert=$1; shift; fi ;; -c|--state_to_modify) shift; if [ -n "$1" ]; then state_to_modify=$1; shift; fi ;; --) shift; break; ;; esac done echo $configname echo $state_to_revert echo $state_to_modify snapper -c $configname -v undochange $state_to_revert..$state_to_modify

Step-8 : Run script to restore older snapshot using Snapper

Run the script using the below command specifying the config name and Snapshot number to which we need to restore.

bash restore.sh –configname –state_to_revert –state_to_modify

Eg:

bash restoretest.sh –configname snapconfig –state_to_revert 1 –state_to_modify 2

Congratulate yourself!

If everything works correctly, you will able to deploy Openstack and restore the server to its original state and redeploy over and over again as needed.

Cover Photo // CC BY NC

This tutorial was written by Arun Kumar, a DevOps engineer at CloudEnablers Inc, a start-up focused on cloud technology based in Chennai, India. This post first appeared on the CloudEnablers blog. Superuser is always interested in community content, email editorATopenstack.org to find out more.