Tech Chorus

Simple Password Vault With Ansible

written by Sudheer Satyanarayana on 2019-02-17

Ansible comes with a vault feature. It is meant to be used in the context of configuration management. But you can also use it as a standalone simple password vault for your personal or organization's use.

Initial setup of password vault:

At this point, your password vault is setup and pushed to your central Git repository. The next time you want to use it on another or same device, here's the flow you could use:

Keep in mind that Git will treat your password vault as a binary file.

Installing Specific Version Of Ruby On CentOS

written by Sudheer S on 2019-01-08

How do you install a specific version of Ruby on CentOS 7?

The answer: via SCL.

The Ansible role bngsudheer.ruby makes it even more easier.

Create the file ruby_playbook.yml and insert the following contents:

- hosts: my_ruby_servers
    ruby_version: 2.3
     - bngsudheer.ruby

Once done, run the Ansible playbook:

ansible-playbook ruby_playbook.yml

What if I want to install Ruby 2.4 on CentOS?

Just set ruby_version to 2.4. Similarly, if you want to install Ruby 2.5, set ruby_version to 2.5.

It is also possible to enable particular version of Ruby on a per-user basis. For example, to enable Ruby 2.5 for the user myproject user, set ruby_enable_users to ['myproject'].

Systemd Unit File Just To Create A Directory Under /run

written by Sudheer Satyanarayana on 2018-01-19

On recent versions of Fedora, CentOS and RHEL, /var/run and /var/lock are mounted as /tmpfs. Also, /var/run is a symlink to /run. Because of this, if you create a directory under /run it won't stay there after a reboot.

If you are starting to migrate your service to systemd or just want to create a directory under /run using systemd, use this simple unit file. The contents of:

Description=My Service

# We just want to create the myservice run directory

Replace my.service with an appropriate name for your service. Replace the description, User and Group values to your needs.

Start the unit:

systemctl start my.service

Enable the unit so that it starts when the system boots:

systemctl enable my.service

What is wrong in using ExecStartPre=-/bin/mkdir /var/run/myservice?

Systemd can handle directory creation and setting up its attributes for you. You just specifiy the name of the directory in the RuntimeDirectory= directory. When the unit starts, systemd creates the directory and sets its owner and group to the values you specify in User= and Group= directives. So, the counter question is, when systemd can do it for you using a simple directive, why do you want to do it yourself? Also, note that the - prefix just ignores the error when the directory already exists and another attempt is made to create it. Although the error is ignored, it still shows up in red when you check the status of the service.

What is Type=oneshot?

Type=oneshot means the process is expected to exit before systemd starts follow-up units. Along with this, we also specify RemainAfterExit=yes. We tell systemd that my.service shall be considered active even when all its processes exited. When you query the status of the service, you will see that the unit is active because of this directive.

What is ExecStart=/bin/true?

Typically, you would put the path to your service executable in ExecStart= directive. In our example, we're not doing that yet. We're simply using the sytemd unit file to create the /run/myservice directory. So, we use the placeholder command /bin/true. /bin/true simply returns 0 indicating that the command was executed successfully.


journalctl Cheatsheet

written by Sudheer Satyanarayana on 2017-10-26

Between date ranges

journalctl --since "2017-10-20" --until "2017-10-21"

Between date and time ranges

journalctl --since "2017-10-20 10:00:00" --until "2017-10-21 11:00:00"

Friendlier unit values of since and until

journalctl --since "2017-10-20 10:00:00" --until "1 hour ago"
journalctl  --since "1 hour ago"
journalctl  --since "2 hour ago"  --until "1 hour ago"

View particular unit

journalctl -u alertmanager

where alertnamaner is the systemd unit name.

Kernel messages

journalctl -k

By priority

journalctl -p crit

Continuously watch like tail -f

journalctl -fu prometheus

Catalogue and jumping to end in the pager

journalctl -xe

This is particularly useful when your last command results in an error and you want to the most recent errors. The -x flag adds useful descriptive messages to errors when they are available.

Installing Latest Version Of Texlive On Fedora

written by Sudheer Satyanarayana on 2017-05-19

The version of textlive shipped with Fedora 25 was too old for my needs.

$ dnf info texlive
Last metadata expiration check: 22 days, 8:44:09 ago on Wed Apr 26 22:34:24 2017.
Available Packages
Name        : texlive
Arch        : x86_64
Epoch       : 6
Version     : 2016
Release     : 33.20160520.fc25
Size        : 33 k
Repo        : updates
Summary     : TeX formatting system
URL         :
License     : Artistic 2.0 and GPLv2 and GPLv2+ and LGPLv2+ and LPPL and MIT and Public Domain and UCD and Utopia
Description : The TeX Live software distribution offers a complete TeX system for a
            : variety of Unix, Macintosh, Windows and other platforms. It
            : encompasses programs for editing, typesetting, previewing and printing
            : of TeX documents in many different languages, and a large collection
            : of TeX macros and font libraries.
            : The distribution includes extensive general documentation about TeX,
            : as well as the documentation for the included software packages.

Specifically, I wanted the updated version of tex4ebook package. The version shipped by Fedora didn't cut it. So, I had to install newer version of textlive only for certain tasks. So, I downloaded and installed texlive on a separate user account.

adduser somenewuser
su - somenewuser

Go to and get the link to the latest tarball.

wget ''

Unpack the archive.

tar -zxvf install-tl-unx.tar.gz
Execute the installer. Your directory name may vary depending on the build number.
cd install-tl-20170413/

In the installation wizard, set the TEXDIR using the D option. I set mine to ~/texlive/2016/.

The installation takes some time. Enjoy the new version of tex4ebook using the path


This way, you can use the Fedora provided version of texlive on your regular user accounts and custom textlive on special user.


written by Sudheer Satyanarayana on 2017-05-14

VIM Plugins And Notes

The plugins I use for Vim. Recently, I have started using Atom for web development. For rest my editing needs, I use Vim.

For General Editing

For Python Development

For JavaScript

Some Cool VIM Resources


written by Sudheer S on 2016-10-02

Rakesh: Golix, what's lucky for you?

Golix: Lucky, I learned probability.

PostgreSQL Cheatsheet

written by Sudheer Satyanarayana on 2016-07-25

Install PostgreSQL server

yum install postgresql-server

New server setup

postgresql-setup initdb

Upgrading from an older version

postgresql-setup --upgrade

Allow password based login

Edit /var/lib/pgsql/data/pg_hba.conf

  host    all     all    md5

Create user

 CREATE USER username login PASSWORD 'password';

Create database

 CREATE DATABASE databasename WITH OWNER = username;

Generate CREATE TABLE statement for a particular table

pg_dump -U username -h dbname -t tablename --schema-only

Using Sass Version Of Bootstrap With Webpack

written by Sudheer Satyanarayana on 2016-07-21

You must have gone through the webpack tutorial to understand this blog post. If you have done that, using Sass version of Bootstrap is a breeze.

In your project directory install these packages using npm.

npm install bootstrap-loader css-loader node-sass resolve-url-loader sass-loader style-loader url-loader file-loader jquery imports-loader bootstrap-sass --save-dev

Create the file webpack.config.js

'use strict';

var path = require('path');

module.exports = {
    entry: ['bootstrap-loader', './index.js'],
    output: {
        path: 'output',
        filename: 'bundle.bootstrap-sass.js'
    devtool: 'inline-source-map',
    module: {
        loaders: [
                test: /bootstrap-sass\/assets\/javascripts\//, 
                loader: 'imports?jQuery=jquery'
                test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
                loader: 'url'
                test: /\.scss$/,
                loader: 'style-loader!css-loader!'
        resolve: {
            extensions: ['', '.js', '.jsx', '.css', '.scss'],
            modulesDirectories: [

index.js: your project entry file.

/* Put whatever you want in your entry JS file */

index.html: Minimalist HTML file to check whether Bootstrap styles are loaded.

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Minimalistic webpage</title>

    <script src="output/bundle.bootstrap-sass.js"></script>

  <body role="document">
     <button type="button" class="btn btn-primary" aria-label="Left Align"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span>Some text</button>

Generate the build


Open index.html in your browser and you should see the web page with Bootstrap styles loaded.

Firewalld Cheatsheet

written by Sudheer Satyanarayana on 2016-07-12

List supported zones

firewall-cmd --get-zones

List active zones

firewall-cmd --get-active-zones

List zones with enabled features

firewall-cmd --list-all-zones

Permanently add source IP address to a zone

firewall-cmd --permanent --zone=<zone_name> --add-source=<ip_address>

Permanently remove source IP address from a zone

firewall-cmd --permanent --zone=<zone_name> --remove-source=<ip_address>

Reload firewall

firewall-cmd --reload

Permanently add a service to zone

firewall-cmd --permanent --zone=<zone_name> --add-service=<service_name>

Permanently add an interface to a zone

firewall-cmd --permanent --zone=<zone_name> --add-interface=<interface_name>

Permanently remove an interface from a zone

firewall-cmd --permanent --zone=<zone_name> --remove-interface=<interface_name>

Adding Custom Service

Copy from a template.

cp /usr/lib/firewalld/services/https.xml /etc/firewalld/services/myservice.xml

and edit the values. If you have an interface alias, this method might suit your needs: