Saturday, November 18, 2017

How to add a user in sudoers

How to add a user in sudoers list?

My OS is CentOS release 6.9 (Final). At the moment I have only root user. I need to create a user and add that user in sudoers.

Login to server as root. - ssh {ip}
Create user- useradd {arun}
Password to that user - password {arun}
usermod -aG wheel {arun}
Run - visudo
Scroll down to the bottom where wheel groups are described.

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
{arun}          ALL=(ALL)       ALL

#
Now login as that user {arun}
sudo ls -la /root

It will ask for password, then list all files in /root directory.

Wednesday, October 11, 2017

Thinking of migration from Ansible to HashiCorp

Convincing clients to move from Ansible to HashiCorp Terraform for provisioning infrastructure on AWS. Hashi is a good team having a lot of efficient products in different cloud technologies. The attached image is one of the most informative slides of the presentation.


Saturday, October 7, 2017

Ansible plugin for Jenkins

I need to utilize my ansible playbook in jenkins. We do have a plugin called Ansible Plugin.
You can install this plugin from jenkins itself. Once you login in jenkins --> Manage Jenkins --> Manage Plugins search for ansible plugin. Select, download and install plugin with restart of jenkins.

What we are doing here in this example:

I had a playbook, which contains two hosts, office.lan and lb.lan, the play book will just print a message "Hello from Ansible!!" when it runs.

Here is my ansible directory structure:

Directory: /home/shivin/Desktop/ansible-workshop
File : main.yml
Other directory: inventories/localdc

Run this play book from shell : 

ansible-playbook main.yml -i inventories/localdc --user root --ask-pass

This will ask for the password and will get a result, if everything is configured correctly.

How we can configure in Jenkins:

First need to give the ansible path in jenkins. Login to Jenkins --> Manage Jenkins --> Global Tool Configuration

Give a name : Ansible<version>
Path to ansible executables directory: /usr/bin/

For job configuration:
In my jenkins job, i am downloading the ansible playbook files from GIT to the workspace.


 Then run the job :)
 

Tuesday, August 22, 2017

Jenkins Pipeline code to run in a particular label


    node('TestLabel') {

        stage('Build') {
           
                echo 'Building..'
           
        }
        stage('Test') {
           
                echo 'Testing..'
           
        }
        stage('Deploy') {
           
                echo 'Deploying....'
           
        }

    }