Most Useful Tools for Chef

useful-tools-for-chef

Useful Tools for Chef 

Chef Code Correctness (Chef Code Analysis)

  • Foodcritic
  • Rubocop

Chef Unit Testing

  • ChefSpec

Chef Integration Testing

  • TestKitchen
  • ServerSpec
  • RSpec

Some other tools which can be used along with Chef

  • dsh
  • gsh

Some other chef & Knife tools

  • knife-lastrun
  • knife-preflight
  • Chef-handlers
  • knife-flip
  • knife-bulkchangeenvironment
  • knife-env-diff
  • knife spork

Chef Tools for Windows

  • POSHChef – POSHChef has been built as a native chef client on Windows using PowerShell.
Tagged : / / / / / / /

How to Implement Chef roles using Chef server ?

implement-chef-roles-using-chef-server

What is Role?

A role is a way to define certain patterns and processes that exist across nodes in an organization as belonging to a single job function. Each role consists of zero (or more) attributes and a run-list. Each node can have zero (or more) roles assigned to it. When a role is run against a node, the configuration details of that node are compared against the attributes of the role, and then the contents of that role’s run-list are applied to the node’s configuration details. When a chef-client runs, it merges its own attributes and run-lists with those contained within each assigned role.

How to use Roles in Chef?

  1. Create a Role and add the cookbooks into it.
  2. Assign the role into each node or bootstrap new nodes using roles
  3. The the run list

How to create Role?

Method 1: In Chef Server directly

> knife role create client1

&

Add the run list e.g. “recipe[nginx]” under “run_list”

Save & exit

The role will be created in Chef Server.

Example

{ "name": "client1", "description": "", "json_class": "Chef::Role", "default_attributes": { }, "override_attributes": { }, "chef_type": "role", "run_list": [ "recipe[nginx]", "recipe[phpapp::web]" ], "env_run_lists": { } } 

Let’s download the role from the Chef server so we have it locally in a Chef repository.

> knife role show client1 -d -Fjson > roles/client1.json

Now, Lets bootstrap the node using knife with roles

> knife bootstrap --run-list "role[client1]" --sudo hostname

How to edit the roles in chef Server?

> knife role edit client1

Method 2: In local repo under chef-repo folder

> vi webserver.rb

example –

name "web_server" description "Role for web servers" run_list(   "role[base]",   "recipe{web_server]" ) 

& Then upload to chef server using following commands.

> knife role from file path/to/role/file

How Assigning Roles to Nodes?

> knife node list
> knife node edit node_name

This will bring up the node’s definition file, which will allow us to add a role to its run_list:

{ "name": "client1", "chef_environment": "_default", "normal": { "tags": [  ] 	}, "run_list": [ 	"recipe[nginx]" ] } 

For instance, we can replace our recipe with our role in this file:

{ "name": "client1", "chef_environment": "_default", "normal": { "tags": [ ] }, "run_list": [ "role[web_server]" ] } 

How to bootstrap node using role?

> knife bootstrap {{address}} --ssh-user {{user}} --ssh-password '{{password}}' --sudo --use-sudo-password --node-name node1 --run-list 'role[production]'
> knife bootstrap --run-list "role[phpapp-web]" --sudo hostname

How to run roles against nodes?

You can run chef-client on multiple nodes via knife ssh command like, To query for all nodes that have the webserver role and then use SSH to run the command sudo chef-client, enter:

> knife ssh "role:webserver" "sudo chef-client"

To find the uptime of all of web servers running Ubuntu on the Amazon EC2 platform, enter:

> knife ssh "role:web" "uptime" -x ubuntu -a ec2.public_hostname

Reference

http://docs.chef.io/roles.html

https://docs.chef.io/knife_ssh.html

https://docs.chef.io/knife_role.html

Tagged : / / / / / / / / / / / / /

How to Setup SVN Server with Apache2 in Ubantu?

setup-svn-server-with-apache2-in-ubantu

This tutorial is to setup the SVNServer from base using Apache2 in Ubantu only.

> sudo apt-get update

> sudo apt-get install subversion apache2 libapache2-svn apache2-utils

> sudo addgroup subversion

> sudo mkdir /home/svn

> sudo chown -R www-data:subversion /home/svn

> sudo chmod -R g+ws /home/svn

> sudo svnadmin create /home/svn/myWebsite

sudo vim /etc/apache2/mods-available/dav_svn.conf

& add the following entry at the end of file.

<Location /svn/myWebsite> DAV svn SVNPath /home/svn/myWebsite AuthType Basic AuthName "myWebsite subversion Repository" AuthUserFile /etc/subversion/passwd <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> </Location>

sudo htpasswd -c /etc/subversion/passwd rajesh

sudo chown -R www-data:subversion /home/svn/myWebsite

sudo chmod -R g+rws /home/svn/myWebsite

sudo /etc/init.d/apache2 restart

sudo htpasswd /etc/subversion/passwd user1

sudo /etc/init.d/apache2 restart

All DONE.

Now you can access the SVN Server using….

http://uvo12exe3iancqqq622.vm.cld.sr/svn/myWebsite/

If you are still not able to open the url, that means you have IPtables services running and stopping you to access the server. For testing, you can stop the sudo ufw stop

Tagged : / / / / / / / / / / / / / /

Jenkins Backup and Restore Process | Jenkins Tutorial

jenkins-backup-and-restore-process

How Do I Backup Jenkins Jobs using Grunt?

Backup Jenkins configuration to S3

bash-backup-script for jenkins‘ job-configs via user-crontab

Backup and restore Jenkins using jenkins plugins

Tagged : / / / / / / / / / / / / / / / /

Chef Commands Line Reference | Chef Commands Line Guide | Cheatsheet

chef-commands-line-reference

To run single recipe using chef-solo

> chef-solo -c /opt/chef/repo/config/solo.rb -o my_cookbook::recipe

To run the single reciepe in same machine

> chef-apply hello.rb

To generate the cookbook standard structure

> chef generate cookbook learn_chef_httpd
> knife cookbook create smartmontools -r md

To generate the template file in cookbook

> chef generate template learn_chef_httpd index.html

To run the cookbook in local mode

> sudo chef-client --local-mode --runlist ‘recipe[learn_chef_httpd]’

To download the cookbooks from market place

> knife cookbook site download learn_chef_httpd
> knife cookbook site install learn_chef_httpd

To Upload the cookbooks to chef server

> knife cookbook upload learn_chef_httpd
> knife cookbook upload -a

To bootstrap a nodes

> knife bootstrap {{address}} --ssh-user {{user}} --ssh-password '{{password}}' --sudo --use-sudo-password --node-name node1 --run-list 'recipe[learn_chef_apache2]'
> knife bootstrap uvo1t75faaktzc532w6.vm.cld.sr -x root -P Br356YS0iy –sudo –node-name firefox
> knife bootstrap 123.45.6.789 -x username -P password –sudo

To see the list of nodes

>knife node list

To edit the node run list

> knife node edit name_of_node

To see the info about each nodes

> knife node show node1

Run the cooksbooks on nodes

> knife ssh {{address}} 'sudo chef-client' --manual-list --ssh-user {{user}} --ssh-password '{{password}}'
> ssh username@ipadddress -i mycredentials.pem sudo chef-client

To add the run list to the nodes.

knife node run_list add C2445575914.domain 'recipe[hptrain]'
knife node run_list set test-node '''recipe[iptables]''' [Windows - Powershell]
knife node run_list set test-node 'recipe[iptables]' [Windows - Command]
Tagged : / / / / / / / / / / / /

DOT NET Build and Release Training | Build and Release DOTNET Course

 

About the Build and Release Dot Net Course
This Training is specially designed for the engineer who wants to excel their career in Build and Release and DevOps domain using Microsoft Platform in DO NET. We are using tools like TeamCity and Jenkins for CIs, apart from MsBuild, NAnt, Octopus, Nuget and Puppet.
Course Objective – Build and Release
After the completion of Build and Release Dot Net course at scmGalaxy, you will be able to :
  1. Understand the need for Build and Release Dot Net and the problems it resolves.
  2. Learn about the common Infrastructure Servers, Scalability and Availability
  3. Implement Automated Installations and Deployments
  4. Understand Performance and basic Security for Infrastructure
  5. Implement Virtualization Concepts
  6. Understand the need and concepts of Monitoring and Logging
  7. Understand the Continuous Integration and Deployment (CI/CD)
  8. Learn various Build and Release Dot Net tools TFS, Puppets, Jenkins, Nagios, Docker, GIT, etc
Who should go for this course?
This course is a foundation to anyone who aspires to become a Build and Release Dot Net Engineer, a Engineer in the field of Enterprise Infrastructures. The following professionals are the key beneficiaries of this course :
  1. DevOps Engineer
  2. Build and Release Engineer,
  3. AppOps Engineer,
  4. Site Reliability Engineer
  5. System Administrator
  6. Operations Engineer
  7. Automation Engineer
This course will also help professionals who is somehow associated with cloud infrasture, managing the team or from development and Testing background.
  1. Project Managers,
  2. Testing Professionals,
  3. Software Developers and Architects,
And have experience with either administering IT infrastructure/applications or with automation
Pre-requisites
  1. Basic understanding of linux/unix system concepts
  2. Familiarity with Command Line Interface (CLI)
  3. Familiarity with a Text Editor
  4. Experience with managing systems/applications/infrastructure or with deployments/automation
How to contact?
  1. email to info@scmGalaxy.com
  2. Phone to +91 9939272785 (India)
  3. Phone to +91 7739774984 (India)
  4. WhatsApp  – +91 9939272785 
  5. Skype – RajeshKumarIN
How to enroll for this training?
Testimonials : What professionals feel about our training?
Please click on this url to know what our student think about training program- Click Here
FAQ : Do you have additional questions?
Please click on this url to know Click Here
Why Online training is more preferred than classroom?
Please click on this url to know Click Here
Classroom Training and Workshop?

We do offer classroom training and workshop in Bangalore, Hyderabad, Pune, Mumbai and New Delhi. For more details, please send us an email to info@scmGalaxy.com

Also, you can follow this url Click Here

Fees Details (Fixed)

With Lifetime Enrollment
DevOps + Build & Release – INR 30K

Without Lifetime Enrollment
DevOps + Build & Release – INR 25K

Training Time and Calender

Please click on this url to know Click Here

Time

  1. 7:00 AM IST to 8:30 AM IST
  2. 8:00 PM IST to 9:30 PM IST
Why to Learn Build and Release
  1. Technical benefits: Continuous software delivery
  2. Technical benefits: Less complex problems to fix
  3. Technical benefits: Faster resolution of problems
  4. Business benefits: Faster delivery of features
  5. Business benefits: More stable operating environments
  6. Business benefits: More time available to add value (rather than fix/maintain)
Course Features: Build and Release
  1. 30 Hours instructor led online class
  2. Hands on Approach – We emphasize on learning by doing.
  3. Life time free re-enrollment to future DevOps courses
  4. Life time free access to all learning materials including
    1. Class recordings
    2. Presentations
    3. Sample Code
    4. Projects
  5. Total Lab Infrasture in cloud and 24×7 available
  6. 70% of the class is consist of Lab
  7. Each week assignments (total 4) with personal assistance
  8. Two real time senario based projects with standard evaluation
  9. 24×7 online support to queries during and after the course completion
  10. 1 dedicated class for Interview preparations
  11. Online Quizs for each tool
  12. Lifetime Free access to Our Learning Portal for FreeVideos, Scripts Collection, Quiz, Interview Guide, Projects, Tutorials etc.
  13. Two Courses One Fee – DevOps and Build & Release which includes Chef and Puppet courses are together is being offered to our students.
  14. Life time Enrollment – Once you enroll, its life time enrollment. That means you can attend any number of session, Any Batch, Any time without paying another time for DevOps, Build & Release, Chef and Puppet. That means all courses, only one fees for life time.

Agenda of the training: Tools and Technologies

Concept and Process

  1. Software Configuration Management overview
  2. Elements of Software Configuration Management
  3. Introduction of Version management / Source Code Management
  4. Overview of Build management
  5. Overview of Packaging management
  6. Build and Release Concept and Process
  7. Overview of Release and Deployment management
  8. DevOps Concept and Process
  9. Continuous Integration and Delivery Process

Operating Systems

  1. Windows Administrator fundamental

Source Code Management

  1. Git Fundamental
  2. Git Advance
  3. Team Foundation Source Code

Build Tools

  1. MsBuild Fundamental
  2. NANT 
  3. Team Foundation Build

Scripting

  1. Powershell Scripting – Fundamental

Package Management in Linux and Windows

  1. Nuget

Artifact Repository Tools

  1. Nuget

Configuration Management Tools

  1. Puppet Fundamental
  2. Puppet Advance
  3. Octopus

Incident Management tools

  1. Jira Fundamental

Continuous Integration Tools

  1. Jenkins Fundamental
  2. Jenkins Advance
  3. Teamcity Fundamental

CI/CD Concept and Implementation

  1. Concept of Continuous Integration
  2. Concept of Continuous Deployment
  3. Concept of Continuous Delivery
  4. CI/CD Implementation
Tagged : / / / / / / / / / / / / / / / / / /

How to Resolve jenkins java.lang.outofmemoryerror permgen space issues?

jenkins-java-lang-outofmemoryerror-permgen-space-issues

Solution 1

In Windows: Go to environment variable and add following variables

export JAVA_OPTS=”-XX:MaxPermSize=512m -Xms512m -Xmx1024m”
export GRADLE_OPTS=”-XX:MaxPermSize=512m”
export SONAR_RUNNER_OPTS=”-Xmx512m -XX:MaxPermSize=512m”

In Linux:
In my ~/.bash_profile file, I have set the following 3 variables. Note there are other variables in this file as well i.e. JAVA_HOME, ANT_HOME, SONAR_HOME, SONAR_RUNNER_HOME, etc:

export JAVA_OPTS=”-XX:MaxPermSize=512m -Xms512m -Xmx1024m”
export GRADLE_OPTS=”-XX:MaxPermSize=512m”
export SONAR_RUNNER_OPTS=”-Xmx512m -XX:MaxPermSize=512m”

Solution 2
You can set the -Xmx or -XX:MaxPermSize in your Jenkins global configuration. To do this, navigate to Jenkins global configuration page (Manage Jenkins -> Configure System)

Name – JAVA_OPTS
Value – “-XX:MaxPermSize=512m -Xms512m -Xmx1024m”

You can set similarlity for maven, gradle, sonar as well under “Maven Project Configuration” or grade project configuration.

Name – GRADLE_OPTS
Value – “-XX:MaxPermSize=512m”

Solution 3

They way you can modify this value depends on the distribution and depending on the slave type

Master

In RedHat, for example, you can do it under /etc/sysconfig/jenkins using the variable JENKINS_JAVA_OPTIONS… i.e JENKINS_JAVA_OPTIONS=”-XX:MaxPermSize=512m”.
In Ubuntu, the Jenkins configuration file is under /etc/default/jenkins and the variable to configure is JAVA_ARGS … i.e JAVA_ARGS=”-XX:MaxPermSize=512m”.

Slave

Sometimes slave machines will require permgen to be increased. Depending on the type of slave that is configured will require a different method for setting any java argument.

With SSH Slaves, the java process is started using an SSH command, so the “-XX:MaxPermSize=512m” can be set in the JVM Options in the Node configuration page.
With JNLP Slaves launching as a service on linux, you can add the VM arguments to the startup scripts (usually in /etc/sysconfig/jenkins or /etc/default/jenkins as part of the JAVA_ARGS variable)
With JNLP Slaves launching as a service on Windows requires modifications to be made on the jenkins.xml file which is located on slave machine in the JENKINS_HOME directory.

Reference
http://stackoverflow.com/questions/18000841/jenkins-java-lang-outofmemoryerror-permgen-space
https://wiki.jenkins-ci.org/display/JENKINS/Builds+failing+with+OutOfMemoryErrors
https://cloudbees.zendesk.com/hc/en-us/articles/204264000-Why-do-I-receive-java-lang-OutOfMemoryError-PermGen-space
http://stackoverflow.com/questions/14762162/how-do-i-give-jenkins-more-heap-space-when-its-running-as-a-daemon-on-ubuntu
http://stackoverflow.com/questions/18000841/jenkins-java-lang-outofmemoryerror-permgen-space
http://javarevisited.blogspot.nl/2011/09/javalangoutofmemoryerror-permgen-space.html
https://plumbr.eu/outofmemoryerror/permgen-space

Tagged : / / / / / / / / /

Jenkins Troubleshooting Guide

jenkins-troubleshooting

Jenkins Troubleshooting

Jenkins is one of the important CI tools which many organization used as part of their Build and DevOps infrasture. I am going to consolidate all the troubshooting techniques which can be used in order to find any issues related in jenkins.

Step 1. Take a look at Log generated by the jenkins and plugins via http://jenkins-master/log

Note: Here you can also create your own logger and and set your custom log levels such as (severe, warning, info, config, file, finer, finest, all)

Step 2. Also, you can look at /var/log/jenkins/jenkins.log via doing “tail -f /var/log/jenkins/jenkins.log” and check carefully whats breaking it.

Log file in windows – jenkins.err.log & jenkins.out.log

Slave log file in windows – logs\slaves

Step 3. Check the system log file

Step 4. Few Jenkins plugins which can you help you
https://wiki.jenkins-ci.org/display/JENKINS/Monitoring

Step 4. Make sure your Jenkins & installed plugins version is installed with most uptodate stable release.

Some Common issues:
Issues 1. If Jenkins hangs, follow https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+is+hanging

Issues 2 Site is down with no 404 messages
Cause- Jenkins had an Out of Memory (OOM) error causing the server to kill the jenkins instance
Solution: Restart server; Review heap logs to identify root cause of error

Issues 3 Site is up however no jobs are displayed
Cause 1: AWS Server rebooted but data volume did not mount properly
Solution: mount <device> <path> on the instance

Issues 4 – java.lang.outofmemoryerror permgen space issues

Solution – http://www.scmgalaxy.com/scm/build-workflow-management/jenkins/jenkins-java-lang-outofmemoryerror-permgen-space-issues.html

Tagged : / / / / / / / / /