Wednesday, March 4, 2020

GetPut Tool to export and import Lucidworks Fusion Application Configurations

Introduction

Extracting configurations of a fusion app in a way such that it can be version controlled is the most common ask.
While the product itself offers distinct apis to fetch specific config or extract entire app as zip,
this script[1] developed by Andrew Shumway[1] enables extracting configs as flat list of json files under
a specific directory, thus allowing us to version control on it.
In this post, I will cover necessary steps to run it and details on what script does and more. 

GetPut script does the following

1. Exporting Fusion apps in a format that is version-control compatible
2) Importing/Deploying exported applications

Installation steps 

GetPut need a local installation of Python 2.7.5 and it lately has support for 3.x (switch git branch for 3.x)
Check for python installation - python -v
Do a git clone to pull the scripts
git clone https://github.com/andrewshumway/fusion-ext.git

Test

To test GetPut, you need a running Lucidworks Fusion instance. An app created on it. 

Steps
1. After "git clone https://github.com/andrewshumway/fusion-ext.git"
2. Navigate to bin directory
3. Choose and copy path to a directory where you'd like to export fusion app configs.
4. Use the below command to get configs

./getApp.sh -u admin -a TestApp --password --dir dir_parth_from_step3/TestApp --keep TestApp_signals,TestApp_signals_aggr ---debug -v

where  
"--keep" to capture configurations that go under Fusion app's ancillary collections. 
"--debug"  and "-v" to get detailed logging about fetching configurations. 
"--dir" location where configurations will be extracted
"-host" need to be passed if it is not "localhost" which is default
"-u" - user
"--password"

5. To deploy an app

./putApp.sh -u admin --password --dir dir_parth_from_step3/TestApp

Other features 

Search and Replace String(hostnames/urls) in config files


One other commonly asked and useful feature offered by this script is "search and replace tokens" in the extracted configurations files. This is useful when there is a need to replace hardcoded hostnames during migrations or replace set of crawl URLS, etc.  It also maintains the copy of original files incase you need to compare what changes took place. 

cd to /fusion-ext/getPut/
./replaceTokens.sh --dir --tokenfile -s

"--dir" location where configurations will be extracted
"--tokenfile" path to file that consist of string that needs to be searched for pipe separated with string to be replaced with.
"-s" this will be the suffix string suffixed to each config file that is backup before performing the above change.

This code runs a "sed" command, just if you'd like to know how it performs search and replace.
sed -i "s|seach_string|replace_string|g" configuration_file


Troubleshooting tips


If you are a newbie python user and do not have some modules that this script uses installed on your box/server,
you may receive an exception, one that's most common is module named “requests” not available.
https://stackoverflow.com/questions/17309288/importerror-no-module-named-requests

"sed" "-i" feature may not work as desired if you have older version of sed installed on your machine. Test if this feature working well otherwise upgrade gnu-sed.


What configurations does it not extract? 
Access Control 
Messaging Services Configuration 
webapps 
license
Recommend


References


[2] Andrew Shumay is currently a Lucidworks Professional Services team member.