StackBuilder is a python class that can install packages on Debian-based OSes. It's primarily used to setup development environments using Vagrant and VirtualBox.
Packages that usually take multiple commands to install are wrapped in a single method. For example, let's consider Nodejs. Currently, the lastest nodejs and npm builds are installed with the following:
$ curl --silent --location https://deb.nodesource.com/setup_5.x | sudo -E bash -$ sudo apt-get install nodejs$ npm install -g npm@latest
With Stackbuilder, this is performed by:
builder=Stackbuilder()
builder.nodejs()- Import the libs directory into your project root. It contains the StackBuilder class and the _init_.py file.
Create a bootstrap.py file in your root directory. This is where you will import and use the StackBuilder class. It should resemble something like this:
#!/usr/bin/env pythonfromstackBuilderimportStackBuilderbuilder=StackBuilder() builder.nginx() builder.vim()
Add the following two lines to your Vagrantfile:
config.vm.provision:file,source: "libs/stackBuilder.py",destination: "/tmp/stackBuilder.py"config.vm.provision"shell",path: "bootstrap.py"
Run the
$ vagrant upcommand from your project directory.