Tuesday, 20 April 2021

Linux Essentials - Introduction ...Modules 1,2,3

 

What is an Operating System?

Every time you switch on your computer, you see a screen where you can perform different activities like write, browse the internet or watch a video. What is it that makes the computer hardware work like that?

How does the processor on your computer know that you are asking it to run a mp3 file?

Well, it is the operating system or the kernel which does this work. A kernel is a program at the heart of any operating system that takes care of fundamental stuff, like letting hardware communicate with software.

So, to work on your computer, you need an Operating System(OS). In fact, you are using one as you read this on your computer. Now, you may have used popular OS's like Windows, Apple OS X but here we will learn what Linux is and what benefits it offers over other OS choices.




 

What is Linux?

Linux is an operating system or a kernel. It is distributed under an open source license. Its functionality list is quite like UNIX.

 

Who created Linux?

 




 

Linux is an operating system or a kernel which germinated as an idea in the mind of young and bright Linus Torvalds when he was a computer science student. He used to work on the UNIX OS (proprietary software) and thought that it needed improvements.

However, when his suggestions were rejected by the designers of UNIX, he thought of launching an OS which will be receptive to


changes, modifications suggested by its users.

 

The Lone Kernel & the early days

So Linus devised a Kernel named Linux in 1991. Though he would need programs like File Manager, Document Editors, Audio -Video programs to run on it. Something as you have a cone but no ice-cream on top.

As time passed by, he collaborated with other programmers in places like MIT and applications for Linux started to appear. So around 1991, a working Linux operating system with some applications was officially launched, and this was the start of one of the most loved and open-source OS options available today.

The earlier versions of Linux were not so user-friendly as they were in use by computer programmers and Linus Torvalds never had it in mind to commercialize his product.

This definitely curbed the Linux's popularity as other commercially oriented Operating System Windows got famous. Nonetheless, the open-source aspect of the Linux operating system made it more robust.

 

Linux gets its due attention




 

The main advantage of Linux was that programmers were able to use the Linux Kernel to design their own custom operating systems. With time, a new range of user-friendly OS's stormed the computer world. Now, Linux is one of the most popular and widely used Kernel, and it is the backbone of popular operating systems like Debian, Knoppix, Ubuntu, and Fedora. Nevertheless, the list does not end here as there are thousands of OS's based on Linux which offer a variety of functions to the users.

 

Linux Kernel is normally used in combination of GNU project by Dr. Richard Stallman. All mordern distributions of Linux are actually distributions of Linux/GNU

 

The benefits of using Linux

Linux now enjoys popularity at its prime, and it's famous among programmers as well as regular computer users around the world. Its main benefits are -

It offers a free operating system. You do not have to shell hundreds


of dollars to get the OS like Windows!



Being open-source, anyone with programming knowledge can modify it.

The Linux operating systems now offer millions of programs/applications to choose from, most of them free! Once you have Linux installed you no longer need an antivirus! Linux is a highly secure system. More so, there is a global development community constantly looking at ways to enhance its security. With each upgrade, the OS becomes more secure and robust

Linux is the OS of choice for Server environments due to its stability and reliability (Mega-companies like Amazon, Facebook, and Google use Linux for their Servers). A Linux based server could run non-stop without a reboot for years on end.

 

Is it for me?










 

Users, who are new to Linux, usually shun it by falsely considering it as a difficult and technical OS to operate but, to state the truth, in the last few years Linux operating systems have become a lot more user- friendly than their counterparts like Windows, so trying them is the best way to know whether Linux suits you or not.

There are thousands of Linux based operating systems; most of them offer state-of-the-art security and applications, all of it for free!

This is what Linux is all about, and now we will move on to how to install Linux and which Distribution you should choose.

 

I am asked to Learn Unix? Then why Linux?

UNIX is called the mother of operating systems which laid out the foundation to Linux. Unix is designed mainly for mainframes and is in enterprises and universities. While Linux is fast becoming a household name for computer users, developers, and server environment. You may have to pay for a Unix kernel while in Linux it is free.


But, the commands used on both the operating systems are usually the same. There is not much difference between UNIX and Linux. Though they might seem different, at the core, they are essentially the same. Since Linux is a clone of UNIX. So learning one is same as learning another.


 

Chapter 2: How to Download & Install Linux (Ubuntu) in Windows

Now that we know what Linux is, it is the time that to learn how we should install it on the computer and choose which Distribution we should use. Let us start by understanding what a Linux Distribution is.

 

What is a Linux Distribution?

Well, now as you know that Linux is open-source, free to use kernel. It is used by programmers, organizations, profit and non- profit companies around the world to create Operating systems to suit their individual requirements.

To prevent hacking attempts, many organizations keep their Linux operating systems private.

Many others make their variations of Linux available publicly so the whole world can benefit at large.

These versions/ types /kinds of Linux operating system are called Distributions.

 

How many distributions are out there?


 

There are hundreds of Linux operating systems or Distributions available these days. Many of them are designed with a specific purpose in mind. For example, to run a web server or to run on network switches like routers, modems, etc.

The latest example of one of the most popular smartphone-based

Linux Distribution is Android!

 

Many of these Distributions are built to offer excellent personal computing.

Here, are a few popular Linux Distributions (also called Linux Distro)

-

 

 

Linux Distribution

Name

Description

 

 

Arch

This Linux Distro is popular amongst Developers. It is an independently developed system. It is designed for users who go for a do-it-yourself approach.

 

 

 

CentOS

It is one of the most used Linux Distribution for enterprise and web servers. It is a free enterprise class Operating system and is based heavily on Red Hat enterprise Distro.

 

 

 

Debian is a stable and popular non- commercial Linux distribution. It is widely


Debian

used as a desktop Linux Distro and is user- oriented. It strictly acts within the Linux protocols.

 

 

 

Fedora

Another Linux kernel based Distro, Fedora is supported by the Fedora project, an endeavor by Red Hat. It is popular among desktop users. Its versions are known for their short life cycle.

 

 

 

Gentoo

It is a source based Distribution which means that you need to configure the code on your system before you can install it. It  is not for Linux beginners, but it is sure fun for experienced users.

 

 

 

LinuxMint

It is one of the most popular Desktop Distributions available out there. It launched in 2006 and is now considered to be the fourth most used Operating system in the computing world.

 

OpenSUSE

It is an easy to use and a good alternative to MS Windows. It can be easily set up and  can also run on small computers with obsolete configurations.

 

 

 

RedHat enterprise

Another popular enterprise based Linux Distribution is Red Hat Enterprise.It has evolved from Red Hat Linux which was discontinued in 2004. It is a commercial Distro and very popular among its clientele.

 

 

Slackware

Slackware is one of the oldest Linux kernel based OS's. It is another easy desktop Distribution. It aims at being a 'Unix like' OS with minimal changes to its kernel.

 

 

 

Ubuntu

This is the third most popular desktop operating system after Microsoft Windows and Apple Mac OS. It is based on the Debian Linux Distribution, and it is known as its desktop environment.

 

The Best Linux Distribution!


The term best is relative. Each Linux distribution is built for a specific purpose-built to meet the demands of its target users.

The desktop Distributions are available for free on their respective websites. You might want to try them one by one till you get to know which Distribution you like the most. Each one of them offers its own unique design, applications, and security.

We will be using Ubuntu for our learning purpose as it's easy for a beginner to understand.

 

Installing Linux

Let's look the various methods we can use to install Ubuntu.

 

Installing Linux using USB stick

 

This is one of the easiest methods of installing Ubuntu or any distribution on your computer. Follow the steps.



Step 1) Download the .iso or the OS files on your computer from this link.

 


 

Step 2) Download free software like 'Universal USB installer to make a bootable USB stick.


 

Step 3) Select an Ubuntu Distribution form the dropdown to put on


your USB

 

Select your Ubuntu iso file download in step 1.

 

Select the drive letter of USB to install Ubuntu and Press create button.


 

Step 4) Click YES to Install Ubuntu in USB.



 

Step 5) After everything has been installed and configured, a small window will appear Congratulations! You now have Ubuntu on a USB stick, bootable and ready to go.


 

Installing Linux using CD-ROM

 

Those who like the way a CD runs should try using this method.


 

(image source)

 

Step 1) Download the .iso or the OS files onto your computer from this link http://www.ubuntu.com/download/desktop.


Step 2) Burn the files to a CD.


 

Step 3) Boot your computer from the optical drive and follow the instructions as they come.

 

Installing Linux using Virtual Machine

 

This is a popular method to install a Linux operating system. The virtual installation offers you the freedom of running Linux on an existing OS already installed on your computer. This means if you have Windows running, then you can just run Linux with a click of a button.

Virtual machine software like Oracle VM can install Ubuntu in easy steps. Let us look at them.

Here the brief steps


 

PART A) Download and Install Virtual Box

 

Download Virtual box using this link

 

Depending on your processor and OS, select the appropriate package. In our case, we have selected Windows with AMD


Once the download is complete, Open setup file and follow the steps below:

Step-1) Click On next


 

Step-2) Select you're the directory to install VirtualBox and click on next


 

Step-3) Select Desktop icon and click on next, now click on yes



 

Step-4) Click On install.


 

Step-5) Now installation of the virtual box will start. Once complete, click on Finish Button to start Virtual Box


 

The virtual box dashboard looks like this-


 

PART B) Download Ubuntu

 

Visit this link to download Ubuntu.



 

You can select 32/64-bit versions as per your choice. PART C) Create a Machine in Virtual Box Step-1) Open Virtual box and click on new button


 

Step-2) In next window, give the name of your OS which you are installing in virtual box. And select OS like Linux and version as Ubuntu 32 bit. And click on next


 

Step-3) Now Allocate Ram Size To your Virtual OS. I recommended keeping 1024mb (1 GB) ram to run Ubuntu better. And click on next.


 

Step-4) Now To run OS in virtual box we have to create virtual hard disk, click on create a virtual hard drive now and click on create button.

The virtual hard disk is where the OS installation files and data/applications you create/install in this Ubuntu machine will reside


 

Step-5) select VHD (virtual hard disk) option and click on next.


 

Step-6) Click on dynamic allocated and click on next. This means that the size of the disk will increase dynamically as per requirement.


 

Step-7) Allocate memory to your virtual hard drive .8GB recommended. Click on create button.


 

Step-8) Now you can see the machine name in left panel


 

So a Machine (PC) with 8GB Hardisk, 1GB RAM is ready.

 

PART D) Install Ubuntu on the Machine Step 1) Select the Machine and Click on Start


 

Step 2) Select the Folder Option


 

Step 3) Select the Ubuntu iso file


 

Step 4) Click Start


 

Step-5) You have an option to Run Ubuntu WITHOUT installing. In this tutorial will install Ubuntu


 

Step-6) Click continue.


 

Step-7) Select option to erase the disk and install Ubuntu and click on install now. This option installs Ubuntu into our virtual hard drive which is we made earlier. It will not harm your PC or Windows installation


 

Step-8) Select your location for setting up time zone, and click on continue


 

Step-9) Select your keyboard layout, by default English (US) is selected but if you want to change then, you can select in the list. And click on continue


 

Step-10) Select your username and password for your Ubuntu admin account. This information has been needed for installing any software package into Ubuntu and also for login to your OS. Fill up your details and tick on login automatically to ignore login attempt and click on continue


 

Step-11) Installation process starts. May take up to 30 minutes. Please wait until installation process completes.


 

Step-12) After finishing the installation, you will see Ubuntu Desktop.


 

Summary

 

An operating system based on the Linux kernel is called a Distribution or Distro

There are hundreds of Distributions available, some of which are designed to accomplish a sole purpose like running servers, act as network switches, etc.

Naming the best Linux Distribution is difficult as they are made for different.

Linux can be installed on your system via the below-mentioned methods:

USB stick Live CD

Virtual Installation


 



Sunday, 14 March 2021

Terms And Conditions

Terms and Conditions Agreement between User and devopstreams.com, its subsidiaries,  Trainers and Coaches. Welcome to devopstreams.com an affiliate of violetstreams.com. The devopstreams.com (“DS”) website (the "Site") is comprised of various web pages operated by Violet Streams Technology and owned by Violet Streams Resources ("VSR"). This is offered to you conditioned on your acceptance without modification of the terms, conditions, and notices contained herein (the "Terms"). Your use of devopstreams.com constitutes your agreement to all such Terms. Please read these terms carefully, and keep a copy of them for your reference. devopstreams.com is an E-Commerce Site. Violet Streams Resources LLC is an e-commerce company designed to become the market leader in Web based sales of Fashion wears, accessories, jewelries and consumer based goods. We also deliver Cloud and DevOps consulting as well as IT based training for numerous Fortune 500 companies and start-ups Privacy Your use of devopstreams.com is subject to VSR's Privacy Policy. Please review our Privacy Policy, which also governs the Site and informs users of our data collection practices. Electronic Communications Visiting devopstreams.com or sending emails to DS constitutes electronic communications. You consent to receive electronic communications and you agree that all agreements, notices, disclosures and other communications that we provide to you electronically, via email and on the Site, satisfy any legal requirement that such communications be in writing. Your Account If you use this site, you are responsible for maintaining the confidentiality of your account and password and for restricting access to your computer, and you agree to accept responsibility for all activities that occur under your account or password. You may not assign or otherwise transfer your account to any other person or entity. You acknowledge that DS is not responsible for third party access to your account that results from theft or misappropriation of your account. DS and its associates reserve the right to refuse or cancel service, terminate accounts, or remove or edit content in our sole discretion. Children Under Thirteen DS does not knowingly collect, either online or offline, personal information from persons under the age of thirteen. If you are under 18, you may use devopstreams.com only with permission of a parent or guardian. Cancellation/Refund Policy, DS has a no refund policy, once payments have been made, there will be no refunds. This also includes all Deposits, Part Payments, Registration Fees and Application fees. All payments received by DS,VSR and VST are nonrefundable. Engaging Third Party Clients, All clients that are middle men to groups or serve as agents that engage DS,VSR and VST in business must make full and complete payments of all fees before they can be serviced by DS,VSR and VST. This includes groups, companies, schools and individuals that seek to engage our services on behalf of others. This is to safeguard our organization's interest and that of the end party as well as that of the third party representing them 

Links to Third Party Sites/Third Party Services devopstreams.com may contain links to other websites ("Linked Sites"). The Linked Sites are not under the control of DS and DS is not responsible for the contents of any Linked Site, including without limitation any link contained in a Linked Site, or any changes or updates to a Linked Site. DS is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement by DS of the site or any association with its operators. Certain services made available via devopstreams.com are delivered by third party sites and organizations. By using any product, service or functionality originating from the devopstreams.com domain, you hereby acknowledge and consent that DS may share such information and data with any third party with whom DS has a contractual relationship to provide the requested product, service or functionality on behalf of devopstreams.com users and customers. No Unlawful or Prohibited Use/Intellectual Property You are granted a non-exclusive, non-transferable, revocable license to access and use devopstreams.com strictly in accordance with these terms of use. As a condition of your use of the Site, you warrant to DS that you will not use the Site for any purpose that is unlawful or prohibited by these Terms. You may not use the Site in any manner which could damage, disable, overburden, or impair the Site or interfere with any other party's use and enjoyment of the Site. You may not obtain or attempt to obtain any materials or information through any means not intentionally made available or provided for through the Site. All content included as part of the Service, such as text, graphics, logos, images, as well as the compilation thereof, and any software used on the Site, is the property of DS or its suppliers and protected by copyright and other laws that protect intellectual property and proprietary rights. You agree to observe and abide by all copyright and other proprietary notices, legends or other restrictions contained in any such content and will not make any changes thereto. You will not modify, publish, transmit, reverse engineer, participate in the transfer or sale, create derivative works, or in any way exploit any of the content, in whole or in part, found on the Site. DS content is not for resale. Your use of the Site does not entitle you to make any unauthorized use of any protected content, and in particular you will not delete or alter any proprietary rights or attribution notices in any content. You will use protected content solely for your personal use, and will make no other use of the content without the express written permission of DS and the copyright owner. You agree that you do not acquire any ownership rights in any protected content. We do not grant you any licenses, express or implied, to the intellectual property of DS or our licensors except as expressly authorized by these Terms. Use of Communication Services The Site may contain bulletin board services, chat areas, news groups, forums, communities, personal web pages, calendars, and/or other message or communication facilities designed to enable you to communicate with the public at large or with a group. This may also include the program WhatsApp group, emails, Jira accounts, Zoom channels or third party collaboration tools employed to facilitate the running of the program (collectively, "Communication Services"). You agree to use the Communication Services only to post, send and receive messages and material that are proper and related to the particular Communication Service. By way of example, and not as a limitation, you agree that when using a Communication Service, you will not: defame, abuse, harass, stalk, threaten or disrupt the program or otherwise violate the legal rights (such as rights of privacy and publicity) of others; publish, post, upload, distribute or disseminate any inappropriate, profane, defamatory, infringing, obscene, indecent or unlawful topic, name, material or information; upload files that contain software or other material protected by intellectual property laws (or by rights of privacy of publicity) unless you own or control the rights thereto or have received all necessary consents; upload files that contain viruses, corrupted files, or any other similar software or programs that may damage the operation of another's computer; advertise or offer to sell or buy any goods or services for any business purpose, unless such Communication Service specifically allows such messages; conduct or forward surveys, contests, pyramid schemes or chain letters; download any file posted by another user of a Communication Service that you know, or reasonably should know, cannot be legally distributed in such manner; falsify or delete any author attributions, legal or other proper notices or proprietary designations or labels of the origin or source of software or other material contained in a file that is uploaded; restrict or inhibit any other user from using and enjoying the Communication Services; violate any code of conduct or other guidelines which may be applicable for any particular Communication Service; harvest or otherwise collect information about others, including e-mail addresses, without their consent; violate any applicable laws or regulations. DS has no obligation to monitor the Communication Services. However, DS reserves the right to review materials posted to a Communication Service and to remove any materials in its sole discretion. DS reserves the right to terminate your access to any or all of the Communication Services at any time without notice for any reason whatsoever. DS reserves the right at all times to disclose any information as necessary to satisfy any applicable law, regulation, legal process or governmental request, or to edit, refuse to post or to remove any information or materials, in whole or in part, in DS's sole discretion. Always use caution when giving out any personally identifying information about yourself or your children in any Communication Service. DS does not control or endorse the content, messages or information found in any Communication Service and, therefore, DS specifically disclaims any liability with regard to the Communication Services and any actions resulting from your participation in any Communication Service. Managers and hosts are not authorized DS spokespersons, and their views do not necessarily reflect those of DS. Materials uploaded to a Communication Service may be subject to posted limitations on usage. You are responsible for adhering to such limitations if you upload the materials. Materials Provided to devopstreams.com or Posted on Any DS Web Page DS does not claim ownership of the materials you provide to devopstreams.com (including feedback and suggestions) or post, upload, input or submit to any DS Site or our associated services (collectively "Submissions"). However, by posting, uploading, inputting, providing or submitting your Submission you are granting DS, our affiliated companies and necessary sublicensees permission to use your Submission in connection with the operation of their Internet businesses including, without limitation, the rights to: copy, distribute, transmit, publicly display, publicly perform, reproduce, edit, translate and reformat your Submission; and to publish your name in connection with your Submission. No compensation will be paid with respect to the use of your Submission, as provided herein. DS is under no obligation to post or use any Submission you may provide and may remove any Submission at any time in DS's sole discretion. By posting, uploading, inputting, providing or submitting your Submission you warrant and represent that you own or otherwise control all of the rights to your Submission as described in this section including, without limitation, all the rights necessary for you to provide, post, upload, input or submit the Submissions. International Users The Service is controlled, operated and administered by DS from our offices within the USA. If you access the Service from a location outside the USA, you are responsible for compliance with all local laws. You agree that you will not use the DS Content accessed through devopstreams.com in any country or in any manner prohibited by any applicable laws, restrictions or regulations. Indemnification You agree to indemnify, defend and hold harmless DS, its officers, directors, employees, agents and third parties, for any losses, costs, liabilities and expenses (including reasonable attorney's fees) relating to or arising out of your use of or inability to use the Site or services, any user postings made by you, your violation of any terms of this Agreement or your violation of any rights of a third party, or your violation of any applicable laws, rules or regulations. DS reserves the right, at its own cost, to assume the exclusive defense and control of any matter otherwise subject to indemnification by you, in which event you will fully cooperate with DS in asserting any available defenses. Arbitration In the event the parties are not able to resolve any dispute between them arising out of or concerning these Terms and Conditions, or any provisions hereof, whether in contract, tort, or otherwise at law or in equity for damages or any other relief, then such dispute shall be resolved only by final and binding arbitration pursuant to the Federal Arbitration Act, conducted by a single neutral arbitrator and administered by the American Arbitration Association, or a similar arbitration This is a service selected by the parties, in a location mutually agreed upon by the parties. The arbitrator's award shall be final, and judgment may be entered upon it in any court having jurisdiction. In the event that any legal or equitable action, proceeding or arbitration arises out of or concerns these Terms and Conditions, the prevailing party shall be entitled to recover its costs and reasonable attorney's fees. The parties agree to arbitrate all disputes and claims in regards to these Terms and Conditions or any disputes arising as a result of these Terms and Conditions, whether directly or indirectly, including Tort claims that are a result of these Terms and Conditions. The parties agree that the Federal Arbitration Act governs the interpretation and enforcement of this provision. The entire dispute, including the scope and enforceability of this arbitration provision shall be determined by the Arbitrator. This arbitration provision shall survive the termination of these Terms and Conditions. Class Action Waiver Any arbitration under these Terms and Conditions will take place on an individual basis; class arbitrations and class/representative/collective actions are not permitted. THE PARTIES AGREE THAT A PARTY MAY BRING CLAIMS AGAINST THE OTHER ONLY IN EACH'S INDIVIDUAL CAPACITY, AND NOT AS A PLAINTIFF OR CLASS MEMBER IN ANY PUTATIVE CLASS, COLLECTIVE AND/ OR REPRESENTATIVE PROCEEDING, SUCH AS IN THE FORM OF A PRIVATE ATTORNEY GENERAL ACTION AGAINST THE OTHER. Further, unless both you and DS agree otherwise, the arbitrator may not consolidate more than one person's claims, and may not otherwise preside over any form of a representative or class proceeding. Liability Disclaimer THE INFORMATION, SOFTWARE, PRODUCTS, AND SERVICES INCLUDED IN OR AVAILABLE THROUGH THE SITE MAY INCLUDE INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN. VIOLET STREAMS RESOURCES LLC AND/OR ITS SUPPLIERS MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE SITE AT ANY TIME. VIOLET STREAMS RESOURCES LLC AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, AVAILABILITY, TIMELINESS, AND ACCURACY OF THE INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS CONTAINED ON THE SITE FOR ANY PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, ALL SUCH INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OR CONDITION OF ANY KIND. VIOLET STREAMS RESOURCES LLC AND/OR ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL VIOLET STREAMS RESOURCES LLC AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OR PERFORMANCE OF THE SITE, WITH THE DELAY OR INABILITY TO USE THE SITE OR RELATED SERVICES, THE PROVISION OF OR FAILURE TO PROVIDE SERVICES, OR FOR ANY INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS OBTAINED THROUGH THE SITE, OR OTHERWISE ARISING OUT OF THE USE OF THE SITE, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF VIOLET STREAMS RESOURCES LLC OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES. BECAUSE SOME STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU. IF YOU ARE DISSATISFIED WITH ANY PORTION OF THE SITE, OR WITH ANY OF THESE TERMS OF USE, YOUR SOLE AND EXCLUSIVE REMEDY IS TO DISCONTINUE USING THE SITE. Termination/Access Restriction DS reserves the right, in its sole discretion, to terminate your access to the Site and the related services or any portion thereof at any time, without notice. To the maximum extent permitted by law, this agreement is governed by the laws of the State of Texas and you hereby consent to the exclusive jurisdiction and venue of courts in Texas in all disputes arising out of or relating to the use of the Site. Use of the Site is unauthorized in any jurisdiction that does not give effect to all provisions of these Terms, including, without limitation, this section. You agree that no joint venture, partnership, employment, or agency relationship exists between you and DS as a result of this agreement or use of the Site. DS's performance of this agreement is subject to existing laws and legal process, and nothing contained in this agreement is in derogation of DS's right to comply with governmental, court and law enforcement requests or requirements relating to your use of the Site or information provided to or gathered by DS with respect to such use. If any part of this agreement is determined to be invalid or unenforceable pursuant to applicable law including, but not limited to, the warranty disclaimers and liability limitations set forth above, then the invalid or unenforceable provision will be deemed superseded by a valid, enforceable provision that most closely matches the intent of the original provision and the remainder of the agreement shall continue in effect. Unless otherwise specified herein, this agreement constitutes the entire agreement between the user and DS with respect to the Site and it supersedes all prior or contemporaneous communications and proposals, whether electronic, oral or written, between the user and DS with respect to the Site. A printed version of this agreement and of any notice given in electronic form shall be admissible in judicial or administrative proceedings based upon or relating to this agreement to the same extent and subject to the same conditions as other business documents and records originally. It is the express wish to the parties that this agreement and all related documents be written in English. Changes to Terms DS reserves the right, in its sole discretion, to change the Terms under which devopstreams.com is offered. The most current version of the Terms will supersede all previous versions. DS encourages you to periodically review the Terms to stay informed of our updates. Contact Us VSR welcomes your questions or comments regarding the Terms: Violet Streams Resources LLC 17350 State Highway 249 Ste 220 #3143 Houston, Texas 77064 Email Address: violetstreamsresources@gmail.com Telephone number: (682) 593-6961

Effective as of September 15, 2020


Saturday, 6 March 2021

Terraform CD Pipeline Setup to Deploy App Servers

Overview

The goal is to implement Devops best practices to run Terraform in Jenkins Pipelines. We will go over the main concepts that need to be considered and a Jenkinsfile that runs Terraform. The Jenkinsfile will consists of parameters that allows us to pass data as variables in our pipeline job. 


  • Install Terraform on Jenkins Server
  • Install Terraform Plugin on Jenkins
  • Configure Terraform
  • Store and Encrypt Credentials in Jenkins
  • Setting up CD Pipeline with Terraform to Deploy App Servers
  • Bash Script to Deploy Artifactory
  • Run Pipeline Job


Install Terraform on Jenkins Server


Use the following commands to install Terraform on Jenkins server and move the binaries to the correct path as shown below.


  • wget https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip
  • unzip terraform_0.12.24_linux_amd64.zip
  • sudo mv terraform /usr/bin/

Install Terraform plugin on Jenkins

Go to Manage Jenkins > Manage Plugins >Available > search Terraform as shown below:

As you can see, Terraform Plugin is already installed on my Jenkins hence why it's displayed in the Installed section.

Store and Encrypt Credentials in Jenkins (Access and Secret Key) 

In this step, we will be storing and encrypting the access and secret key in Jenkins to maximize security and minimize the chances of exposing our credentials.

    • Go to Manage Jenkins > Manage Credentials > Click on Jenkins the highlighted link as shown below


    • Select Add Credentials
    • Choose Secret text in the Kind field
    •  Enter the following below:
    Note: Modify the yellow highlighted text with the right value.
      • Secret = EnterYourSecretKeyHere
      • ID = AWS_SECRET_ACCESS_KEY
      • Description = AWS_SECRET_ACCESS_KEY
    Click OK

    Add another credential and enter the following:

      • Secret = EnterYourAccessIDHere
      • ID = AWS_ACCESS_KEY_ID
      • Description = AWS_ACCESS_KEY_ID

    Click OK





    Configure Terraform

    Go to Manage Jenkins > Global Tool Configuration > It will display Terraform on the list.

    • Enter terraform in the Name field
    • Provide the path /usr/bin/ as shown below




    Setting up CD Pipeline for Terraform

    • Go to Jenkins > New Items. Enter terraform-pipeline in name field > Choose Pipeline > Click OK


    • Select Configure after creation.
    • Go to Build Triggers and enable Trigger builds remotely.
    • Enter tf_token as Authentication Token

     

    Bitbucket Changes
      • Create a new Bitbucket Repo and call it terraform-pipeline
      • Go to Repository Settings after creation and select Webhooks
      • Click Add Webhooks
      • Enter tf_token as the Title
      • Copy and paste the url as shown below
                  http://JENKINS_URL:8080/job/terraform-pipeline/buildWithParameters?token=tf_token
      • Status should be active
      • Click on skip certificate verification
      • triggers --> repository push
    • Go back to Jenkins and select Configure
    • Scroll down to Pipeline and click on the drop down to select Pipeline Script From SCM
    • Enter credentials for Bitbucket, Leave the Branch master as the default, Make sure script path is Jenkinsfile
    • Right click on Pipeline Syntax and open in a new tab. 
    • Choose Checkout from Version Control in the Sample Step field
    • Enter Bitbucket Repository URL and Credentials, leave the branches blank
    • Click GENERATE PIPELINE SCRIPT, copy credentialsId and url (This is required for Jenkinsfile script)



    Create Workspace for Terraform Pipeline
    • Open File Explorer, navigate to Desktop and create a folder cd_pipeline

    • Once folder has been created, open Visual Code Studio and add folder to workspace







    • Open a New Terminal
    • Run the command before cloning repo: git init
    • Navigate to terraform-pipeline repo in Bitbucket
    • Clone the repo with SSH or HTTPS
    • Create a new file main.tf and copy the below code in yellow color



















    provider "aws" {
    region = var.region
    version = "~> 2.0"
    }
    resource "aws_instance" "ec2" {
    user_data   = base64encode(file("deploy.sh"))
    ami = "ami-0782e9ee97725263d"   ##Change AMI to meet OS requirement as needed.
    root_block_device {
        volume_type           = "gp2"
        volume_size           = 200
        delete_on_termination = true
        encrypted             = true
      }
    tags = {
    Name = "u2-${var.environment}-${var.application}"
    CreatedBy = var.launched_by
    Application = var.application
    OS = var.os
    Environment = var.environment
    }
    instance_type = var.instance_type
    key_name = "Enter_KEYPAIR_Name_Here"
    vpc_security_group_ids = [aws_security_group.ec2_SecurityGroups.id]
    }
    output "ec2_ip" {
    value = [aws_instance.ec2.*.private_ip]
    }
    output "ec2_ip_public" {
    value = [aws_instance.ec2.*.public_ip]
    }
    output "ec2_name" {
    value = [aws_instance.ec2.*.tags.Name]
    }
    output "ec2_instance_id" {
    value = aws_instance.ec2.*.id


    • Create a new file security.tf and copy the below code in yellow color

    resource "aws_security_group" "ec2_SecurityGroups" {
    name = "u2-${var.environment}-sg-${var.application}"
    description = "EC2 SG"
    ingress {
    from_port = 22
    to_port = 22
    protocol = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
    }
    ingress {
        from_port   = 8081
    to_port     = 8081
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
      }
    ingress {
         from_port   = 8082
    to_port     = 8082
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
       }
      ingress {
    from_port = 80
    to_port = 80
    protocol = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
    }
    #Allow all outbound
    egress {
    from_port = 0
    to_port = 0
    protocol = "-1"
    cidr_blocks = ["0.0.0.0/0"]
    }
    }

    • Create a new file variable.tf and copy the below code in yellow color. 

    variable region {
      type        = string
      default = "us-east-2"
    }
    variable "instance_type" {}
    variable "application" {}
    variable "environment" {}
    ############## tags
    variable os {
      type        = string
      default = "Ubuntu"
    }
    variable launched_by {
      type        = string
      default = "USER"
    }
    ############## end tags


    Bash Script to Deploy Artifactory

    • Create a new file deploy.sh and copy the below code in yellow color. 
    #!/bin/bash
    set -x

    exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 

    echo ""
    echo "........................................"
    echo "Installation of application"
    echo "........................................"
    echo "Today's date: `date`"
    echo "........................................"
    echo ""
    sudo pip install awscli
    sudo apt-get install -y unzip
    sudo apt update
    sudo apt dist-upgrade
    sudo apt autoremove
    sudo apt update
    sudo apt-get install openjdk-8-jdk openjdk-8-doc
    java -version
    sudo apt install wget software-properties-common
    sudo wget -qO - https://api.bintray.com/orgs/jfrog/keys/gpg/public.key | sudo apt-key add - 
    sudo add-apt-repository "deb [arch=amd64] https://jfrog.bintray.com/artifactory-debs $(lsb_release -cs) main"
    sudo apt update
    sudo apt install jfrog-artifactory-oss
    sudo systemctl stop artifactory.service
    sudo systemctl start artifactory.service
    sudo systemctl enable artifactory.service
    sudo systemctl status artifactory.service
    echo ""
    echo "........................................"
    echo "Installation of application"
    echo "........................................"
    echo "Today's date: `date`"
    echo "........................................"
    echo ""




    • Create a new file Jenkinsfile and copy the below code in yellow color. 



    pipeline {
        agent{ label '!master' }
        parameters {
            string(name: 'AppName', defaultValue: 'Enter App Name', description: 'Name of application', )
            choice(choices: ['master', 'dev', 'qa', 'prod'], description: 'Select lifecycle to Deploy', name: 'Branch')
            choice(choices: ['t2.micro', 't2.small', 't2.medium'], description: 'Select Instance Size', name: 'InstanceSize')
            booleanParam(name: 'autoApprove', defaultValue: false, description: 'Automatically run apply after generating plan?')
        }


         environment {
            AWS_ACCESS_KEY_ID     = credentials('AWS_ACCESS_KEY_ID')
            AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY')
            TF_VAR_instance_type = "${params.InstanceSize}"
            TF_VAR_environment = "${params.Branch}"
            TF_VAR_application = "${params.AppName}"
        }
    // 

        stages {
          stage('checkout') {
            steps {
                echo "Pulling changes from the branch ${params.Branch}"
                git credentialsId: 'paste-credentialsId-here', url: 'paste-url-here' , branch: "${params.Branch}"
            }
          }

            stage('terraform plan') {
                steps {
                    sh "pwd ; terraform init -input=true"
                    sh "terraform plan -input=true -out tfplan"
                    sh 'terraform show -no-color tfplan > tfplan.txt'
    }
                }
            
            stage('terraform apply approval') {
               when {
                   not {
                       equals expected: true, actual: params.autoApprove
                   }
               }

               steps {
                   script {
                        def plan = readFile 'tfplan.txt'
                        input message: "Do you want to apply the plan?",
                        parameters: [text(name: 'Plan', description: 'Please review the plan', defaultValue: plan)]
                   }
               }
           }

            stage('terraform apply') {
                steps {
                    sh "terraform apply -input=true tfplan"
                }
            }
            
            stage('terraform destroy approval') {
                steps {
                    input 'Run terraform destroy?'
                }
            }
            stage('terraform destroy') {
                steps {
                    sh 'terraform destroy -force'
                }
            }
        }

      }

    • Commit and push code changes to Repo with the following:
      • In Vscode, navigate to Source Code Icon on the right tabs on the side
      • Enter commit message
      • Click the + icon to stage changes 

      • Push changes by clicking on the ðŸ”„0 ⬇️ 1 ⬆️ as shown below

    Run Pipeline Job

    • Go to terraform-pipeline on Jenkins and run build 
    Note: The pipeline job will fail the first time to capture the parameters in Jenkinsfile

    • The next time you run a build you should see as shown below





    • Enter Artifactory in the AppName field
    • Select a Branch/Lifecycle to deploy server
    • Choose t2.small or t2.medium for Artifactory server.
    • Go to Console Output to track progress
    Note: You can abort the destroy step and rerun the step by installing Blue Ocean Plugin on Jenkins to delete the resources created.


    How to upgrade Maven

      java.lang.IllegalStateException I had installed maven in my ubuntu using command  apt install maven This installed maven in path /usr/shar...