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....'
           
        }

    }

Tuesday, August 15, 2017

Mongodb integration with PHP

In my CentOs box, i installed php5.5 and mongodb. Now i am getting the error
Mongodb is not enabled with PHP.

Solution to fix the issue.

Install gcc php-pear php-devel
yum install gcc php-pear php-devel php5-dev openssl-devel -y 

pecl install mongo
Cyrus SASL as "no"

vim /etc/php.ini
extension=mongo.so

Restart apache
service httpd restart

Verify
php -m | grep -i mongo

 
 

323 packages excluded due to repository priority protections

When I run "yum update php*" operation, in CentOs i am getting the following error:

"323 packages excluded due to repository priority protections"

Solution to fix the issue:

This is because of the plugin "priorities" helps to solve this issue. Open the file
/etc/yum/pluginconf.d/priorities.conf  and change the value of enabled =1 to 0.

Execute  yum update php*

It works.

Thursday, August 10, 2017

jq - How we can use jq

jq - JSON processor. We can use this to parse a JSON file in bash scripts. Its an opensource and available in github. We can use this like our sed, awk and grep.

How we can install jq on Centos machine?

jq has no runtime dependencies as its written in C. We need to download and extract to use it. You can play around with jq from here.

wget -O jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
chmod +x ./jq
cp jq /usr/bin