Ansible Role to Install Nodejs on Linux

Posted By : Jatin Gupta | 22-Mar-2018

What is ansible?

Ansible is a powerful IT automation tool that can help you to configure, deploy and orchestrate various machines from one system.
An example is, suppose you have a cluster of 10 web servers, and you want to update a configuration in each of the web servers. Configuring each server manually will take a lot of time, here Ansible comes handy. You can create a playbook in ansible to update the changes and run it on all 10 servers simultaneously.

One can also create Roles in Ansible. Roles are ways of loading vars file, tasks, handlers etc based on a particular directory structure. 

To create a role-based directory structure in Ansible

ubuntu@ubuntu:~$ ansible-galaxy init role_name

 

ANSIBLE ROLE: Node.js

This blog will guide you to install any version of Nodejs on RHEL/Centos or Debian/Ubuntu

 

There can be various scenarios where you want to install node on multiple servers. One such case I faced was when I had to configure log.io for logs of applications running on 20 servers. Log.io requires nodejs to work. So, to achieve the same, I created an Ansible role for Node and ran it on 15 servers simultaneously.
You can use the same role for installing any version of a node for any specific user.

 

Let's get started.

To use the role

 

Requirements :

None

 

Role Variables :

Available variables are listed below and can be found in vars/main.yml

node_version : "6.9.0"  

The nodejs version you wish to install. example "7.9", "4.9"

user_name : testuser

The user for whom the name will be installed.

 

Dependencies :

None

 

Example Playbook

-
  hosts: utilities
  roles:
     - Jating7413.node

 

Author Information

This role was created in 2018 by Jatin Gupta

Ansible Galaxy URL: https://galaxy.ansible.com/Jating7413/node/

To download source code of the role: https://github.com/Jating7413/ansible-role-node

 

 

About Author

Author Image
Jatin Gupta

Jatin is a DevOps trainee. He ha deep interest in python and cloud technologies. He likes to read about science/history and fiction, listening to music and explore new places.

Request for Proposal

Name is required

Comment is required

Sending message..