Sunday, February 26, 2017

DevOps toolchain configuration



How to configure Git & GitHub in Eclipse


How to trigger build automatically in Jenkins


How to configure a Maven Build in Jenkins


How to configure SonarQube in Jenkins


How to configure Cucumber in Eclipse & Jenkins


How to deploys code into Docker containers using Jenkins


How to configure puppet master & puppet agent


How to configure Nagios server and Nagios host


Tuesday, February 21, 2017

Continuous Testing - Integrating Cucumber Maven Project in Jenkins

DevOps: Continuous Testing - Cucumber


Create a Maven project in Eclipse

Create a maven project -> Create a simple project -> Update group ID, artefact ID -> Update pom.xml with latest cucumber – Junit dependency xml tag-> Update pom.xml with latest cucumber – Java dependency xml tag -> Update pom.xml with latest maven – Junit dependencies xml tag-> Update pom.xml with latest maven - selenium dependency xml tag-> Press ^S ->


Create a cucumber feature file

Add the plugin from https://cucumber.io/cucumber-eclipse/update-site -> Create feature file in a separate folder - > Add feature syntax given, when & then -> Add a test package -> Add a class in test package with syntax @RunWith(Cucumber.class) & @CucumberOptions(features=””,glue={“”} -> Add feature location and add step definition as glue -> Run the project as cucumber feature to get skeleton step code -> Create a step definition package – Add a class -> Add feature skeleton code in the step definition class -> Modify the skeleton code -> run the project as junit test -> Run as maven project with goal as (clean build) ->


Create a Maven build job in Jenkins

Create a Maven project in Jenkins –> Update the pom.xml location -> Run the maven project with option clean & install.


Tuesday, February 7, 2017

Continuous Monitoring - Configuring Nagios Server and Nagios Host in Docker Containers

DevOps:Continuous Monitoring:Nagios in Docker Containers


Install Nagio server image in docker container

Select a Nagios image -> download the image (docker pull appcontainers/Nagios) -> Create the docker container (docker run -d -it --name nagiosserver -h nagios -p 8181:80 appcontainers/Nagios) -> Configure a Nagio user in Nagios server command prompt (htpasswd -c -b /etc/nagios/passwd username password) -> Login to Nagios server from browser with the help of user created in previous step (http://localhost:8181/nagios/) ->


Install & configure a Nagios host in docker container

Download a server(ubuntu/centos) image (docker pull nuagebec/Ubuntu) -> Create the docker container (docker run -d -p 0.0.0.0:2222:22 nuagebec/Ubuntu)-> Install NRPE server plugin in the server container (sudo apt-get install nagios-nrpe-server nagios-plugins)-> Update server address and port in nrpe.cfg file (server_address=172.17.0.02, server_port=8181) ->


Configure Nagios host in Nagios server

Update server folder location in Nagios.cfg file in Nagios server (cfg_dir=/etc/nagios/servers) -> Add server folder in Nagios server (mkdir -p /etc/nagios/servers ) -> Create a configuration file in Nagios host and save in the server folder (vim /etc/nagios/servers/ubuntu_host.cfg ) ->


Test the Nagios host configuration update

Restart NRPE service server in Nagios host (service nagios-nrpe-server restart)-> Restart Nagios service in Nagios server (service nagios restart)-> Open the Nagios server browser and verify Nagios host has been added.


Friday, January 27, 2017

Continuous Quality - SonarQube Configuration in Jenkins

DevOps - Continuous Integration : SonarQube Configuration in Jenkins


Install SonarQube in CI server

Download latest SonarQube from https://www.sonarqube.org/downloads and install in your CI server, or for Mac machines brew command can be used alternatively - brew update - brew install sonar ->


Configure & start the sonarQube server

Create sonar database in local server using database queries - CREATE DATABASE sonar_source; - CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar'; - GRANT ALL PRIVILEGES ON sonar_source.* TO 'sonar'@'localhost'; - FLUSH PRIVILEGES; -> Update database details in sonar properties file using command - $ vim /usr/local/Cellar/sonarqube/6.1/libexec/conf/ sonar.properties -> Start the sonar server using command - $ sonar console ->


Configure SonarQube in Jenkins

Install SonarQube plugin in Jenkins using option - Manage Jenkins - Manage Plugins -> Update sonarQube server detail using option - Manage Jenkind - Configure System ->


Create SonarQube build job in Jenkins

Create a maven build job using option - new item -> Check ‘Prepare SonarQube Scanner environment’ under build Environment -> Update pom.xml url in ROOT POM -> Select ‘sonarQube analysis with maven’ under Post-build Actions ->


Run the sonarQube build job & view SonarQube report in Jenkins

Run the build -> Upon successful run, click ‘SonarQube’ icon to view SonarQube code analyzer report.


Monday, January 23, 2017

Continuous Deployment - Puppet master & puppet agent in docker containers

Installing & Running puppet server(master) & puppet agent in docker containers


Create puppet docker containers

Choose a suitable & stable puppet image from dockerhub and install in your docker server -> $ docker pull devopsil/puppet ->


Alternatively, create your own docker file ->


Install a docker container with a suitable puppet master name -> $ Docker run --name puppetmaster -it devopsil/puppet bash -> Install another docker container with a suitable puppet agent name -> $ Docker run --name puppetagent -it devopsil/puppet bash ->

Configure hostname in puppetmaster container with a meaningful name in network file -> # vi etc/sysconfig/network -> HOSTANME=master.demo.com -> Configure hostname in puppetagent container with a meaningful name in network file -> # vi etc/sysconfig/network -> HOSTNAME=agent.demo.com ->

Configure hostname in puppetmaster & puppetagent with same name in hosts file -># vi etc/hosts -> [masterip] 172.17.0.2 master.demo.com -> [agentip] 172.17.0.3 agent.demo.com ->

Ping master form agent and agent from master to test network connection between puppetmaster & puppetagent containers->


Install puppet server & puppet agent in docker containers

Install puppet server in puppetmaster container -># yum install –y puppet puppet-server facter -> install puppet agent in puppetagent container -># yum install –y puppet facter ->


Update puppet.conf file under [main] in puppetmaster container -># vi etc/puppet/puppet.conf -> certname = master.demo.com -> Update puppet.conf file in puppetagent container -># vi etc/puppet/puppet.conf -> server = master.demo.com ->


Start puppet master in puppetmaster container -># service puppetmaster start -># service puppetmaster status ->


Authenticate puppet agent in puppet master

Request certification from agent -># puppet agent --test –server=[master hostname]master.demo.com --waitforcert=50 -> check for certificate request in master -># puppet cert list -> sing certification in master -># puppert cert sign [agent hostname]agent.demo.com ->


Test an example

Create a puppet policy file in puppet master in manifest folder -> # vi etc/puppet/manifest/site.pp ->


Apply the configuration change in puppet agent -># Puppet agent –-test


Thursday, January 12, 2017

Continuous Deployment Automation : Git -> Jenkins -> Docker

DevOps - continuous deployment automation using Git, Jenkins & Docker


Create a Git repository ->


Create a Dockerfile (- to build a container for a php web application shown above in video as an example) inside the Git repository ->


Create other components (index.php under src folder in above example) in the git repository needed to run the designated application inside a docker container -> Change one of these components to git commit the change and trigger a Jenkins build ->


Create a Jenkins freestyle project in Jenkins -> Update the above created Git repository location under SCM configuration of the project -> Select trigger builds remotely and input an authorization token in the configuration ->


Update .git/hooks/post-commit file with a syntax to trigger the Jenkins job created in above step -> Update .git/hooks/post-commit file with a syntax to execute docker commands to create and run a docker container using a Dockerfile ->


Docker commands can be put in an executable file (buildExecutable in this case) ->


Commit the change made (-in one of above steps) in application component -> post-commit of .git/hooks folder will trigger the Jenkins build job -> post-commit will also execute docker commands to build and run a docker container running an application within (a php web application in this case).


Wednesday, January 4, 2017

Continuous Integration Automation : Eclipse -> Selenium -> Git -> Jenkins

DevOps - Continuous Integration Automation using Eclipse, Selenium, Git & Jenkins


Create a maven project in Eclipse -> Create a simple project -> update group ID & artifact ID -> add a package into the project -> add a class into the package->


Update selenium & TestNG dependencies in POM xml file -> Add maven build plugins in POM xml -> Convert the class created in earlier step into a TestNG.xml file -> Save the TestNG.xml file into src/main/resource folder -> Update the location of TestNG file in POM xml under surefire plugin ->


Save the selenium project into a Git repository -> Commit file and folder structure of the project into Git repository -> Make sure Jenkins user have read & write access to this Git repository -> If required clean the repository by running maven clean job with appropriate access ->


Create a maven job in Jenkins -> Update the Git repository url in the job configuration -> Update the location of pom.xml file in job configuration -> Save the maven build job ->


Run the maven build job in Jenkins from Eclipse.