How to Setup AWS Credentials using AWS Command Line Interface?

setup-aws-credentials-using-aws-command

Setup AWS Credentails using AWS Command Line Interface

Install the AWS CLI Using Pip
Please click here complete installation guide.

Test the AWS CLI Installation

 $ aws help

Environment Variables – 

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

Step 5: Get a key aws_access_key_id, aws_secret_access_key, region from AWS website, under your 

$ aws configure

Step 6: Setup AWS with key

$  aws configure
AWS Access Key ID [None]: AKIAJB6WCXXXXRKRT5SQ
AWS Secret Access Key [None]: fDBVPhlHzMk70ip5FGHDl/AcmEyMnylwOllc+n4s
Default region name [None]: us-east-1
Default output format [None]:
$  aws s3 list

Step 7: Verify details in ~/.aws/credentials and ~/.aws/config

$ more ~/.aws/credentials
[default]
aws_access_key_id = AKIAJB6WCXXXXRKRT5SQ
aws_secret_access_key = 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

$  more ~/.aws/config
[default]
region = us-east-1

Step 8: Verify AWS CLI setup

$ aws ec2 describe-instances --output table --region us-west-2

The AWS credentials file –

Located at ~/.aws/credentials on Linux, OS X, or Unix, or at C:\Users\USERNAME \.aws\credentials on Windows. This file can contain multiple named profiles in addition to a default profile.

The CLI configuration file –

Typically located at ~/.aws/config on Linux, OS X, or Unix, or at C:\Users\USERNAME \.aws\config on Windows. This file can contain a default profile, named profiles, and CLI specific configuration parameters for each.

Reference
http://docs.aws.amazon.com/cli/latest/userguide/installing.html
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html

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

Provision a AWS ec2 vm using chef | Step by Step Guide | AWS ec2 vm Tutorial

provision-a-aws-ec2-vm-using-chef

Provision a AWS ec2 vm using chef

Step 1: Install chefdk

Step 2: Setup AWS Credentails

Step X: Setup your knife config

Step X: Make sure following is set and exported in env.

 

AWS_ACCESS_KEY_ID=secrets AWS_SECRET_ACCESS_KEY=secrets AWS_DEFAULT_REGION=us-east-1 AWS_SSH_KEY=your_ssh_key_name AWS_ACCESS_KEY=secrets AWS_SECRET_KEY=secrets

 

Step 3: Genrate a new repository using the chef generate command

> chef generate repo chefdk-provision-demo
> cd chefdk-provision-demo

Step 4: Generate a provision cookbook. This is the required name, and it must be in the current directory.
> chef generate cookbook provision

Step 5: Edit the default recipe, $EDITOR provision/recipes/default.rb with following code…

context = ChefDK::ProvisioningData.context with_driver 'aws::us-west-2' options = { ssh_username: 'admin', use_private_ip_for_ssh: false, bootstrap_options: { key_name: 'jtimberman', image_id: 'ami-0d5b6c3d', instance_type: 'm3.medium', }, convergence_options: context.convergence_options, } machine context.node_name do machine_options options action context.action converge true end

Understand the code:
> To break this down, first we get the ChefDK provisioning context that will pass in options to chef-provisioning.
> Then we tell chef-provisioning to use the AWS driver, and in the us-west-2 region.
> The options hash is used to setup the instance.
> We’re using Debian 8, which uses the admin user to log in, an SSH key that exists in the AWS region, the actual AMI, and finally the instance type.
> Then, we’re going to set the convergence options automatically from ChefDK. This is the important part that will ensure the node has the right run list.

Step 6: Generate a Policyfile.rb and And edit its content, $EDITOR Policyfile.rb.
> chef generate policyfile
> vi policyfile.rb

name            "chefdk-provision-demo" default_source  :community run_list        "recipe[libuuid-user]" cookbook        "libuuid-user"

Here we’re simply getting the libuuid-user cookbook from Supermarket and applying the default recipe to the nodes that have this policy.

Step 7: The next step is to install the Policyfile. This generates the Policyfile.lock.json, and downloads the cookbooks to the cache, ~/.chefdk/cache/cookbooks. If this isn’t run, chef will complain, with a reminder to run it.

> chef install

Step 8: Finally, we can provision a testing system with this policy:

> chef provision testing –sync -n debian-libuuid

Reference:
http://jtimberman.housepub.org/blog/2015/05/15/quick-tip-chefdk-provision/

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

How to install chefDK in RHEL, Ubantu, Mac and Windows?

chefdk-installtion-process-rhel-ubantu-mac-windows
How to install chefDK in RHEL, Ubantu, Mac and Windows?
How to install chefDK in RHEL
Step 1: Download checfdk from https://downloads.chef.io/chef-dk/
or
> chmod 755 chefdk-0.9.0-1.el6.x86_64.rpm
Step 2: Install chef dk
> rpm -ivh chefdk-0.9.0-1.el6.x86_64.rpm
Step 3: Confirm your installation.
> which chef
> chef -v
Install folder is – /opt/chefdk
Tagged : / / / / / / / / / / / / / / / / / / /

How to Install and Configure Jira in Linux | Jira Tutorial

jira-installation-and-configuration-in-linux

Download JIRA package from 

https://www.atlassian.com/software/jira/download?b=j

Linux Installation:

wget https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-6.4.12-x64.bin

chmod atlassian-jira-6.4.12-x64.bin

Execute the ‘.bin’ file to start the console wizard

stop iptables

service jira start/stop

http://uvo1kievugg76unbcj9.vm.cld.sr:8080/

& follow the instructions

Reference

https://confluence.atlassian.com/jira/installing-jira-on-linux-191501165.html

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

How to Install and Configure Nagios Server and Clients | Nagios Tutorial

install-and-configure-nagios-server-and-clients
Install and Configure Nagios Server and Clients
Download the Nagios Server Source copy from https://www.nagios.com/products/nagios-xi/
You can also use the direct download links as below;
> wget https://assets.nagios.com/downloads/nagiosxi/5/xi-5.2.0.tar.gz
Extract the xi-5.2.0.tar.gz using
> tar -zxvf xi-5.2.0.tar.gz
Run the following commands to install it.
> ./fullinstall
At the end of installation, you will get the url address  using you can access the Nagios server.
e.g http://10.160.34.98/nagiosxi/
Open the url http://10.160.34.98/nagiosxi/
and enter and save following info.
Administrator Name:
Administrator Email Address:
Administrator Username:
Administrator Password:
and presss “Install”
Once you get “Installation Complete” message that means you have Nagios Server install completed.
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 : / / / / / / / / / / / / /

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 : / / / / / / / / / / / / / / / /