Almost every month or oftener I can see posts on dev.to and other sites on how people manage their bashrc/dot files using git and bash.
It's ok to use those tools to manage your servers configuration, but let me show your more flexible and powerful way.
Sparrow is a tool to effectively manage and port servers configurations.
The approach consists of following steps:
Define pieces of configurations as sparrow tasks
Save tasks as plain old files in local directory
Push files to remote git repository
On target server clone tasks through
git clonefrom remote git repository
Finally run tasks to apply desired configurations
It might seem extra steps here in comparison with
git push / git pull approach but gives your flexibility and power.
Complex configurations get split to tiny bits which are easier to manage.
Because sparrow tasks are not just configuration, it's possible to run extra steps required to configure your server ( install packages and so on )
For simplicity I confine my post to 2 simple use cases.
- Configuring nano editor ( some basic settings )
- Configuring git global settings ( name and email )
Sparrow comes with a lot of plugins, so you don't need to code anything, just use existed ones:
$ sparrow index update # get the latest updates of sparrow repository $ sparrow plg install nano-rc $ sparrow plg install git-base
Now having installed plugins let's create a couple of tasks to reflect desired settings.
For git setup:
$ sparrow project create git $ sparrow task add git setup git-base $ sparrow task ini git/setup install_git: on email: email@example.com name: Alexey Melezhik
For nano configuration file:
$ sparrow plg install nano-setup $ sparrow task add nano rc nano-setup $ sparrow task ini nano/rc tabsize: 2 speller: hunspell -x -c
If we list our current task now we could see them here:
sparrow root: [/home/suslik/sparrow] [sparrow task list] [utils] git/setup nano/rc
The rest of workflow is similar to saving dotfile to GitHub repository. We will use
sparrow task save command to save tasks to directory and then push files to git:
$ mkdir tasks $ git init . $ git remote add origin https://github.com/user/tasks.git $ sparrow task save $PWD $ git add . && git commit -a -m "my sparrow tasks" && git push
Once tasks are saved to git repository we can install them on any server:
$ git clone https://github.com/user/tasks.git my-tasks $ sparrow task restore my-tasks
We are all set. To start using our task just run:
$ sparrow task run git/setup # set up my git client $ sparrow task run nano/rc # configure nano editor
Finally here is my tasks repository - take a look at it as an example.
Thank you for reading.