DevOps Engineering part 4. – Connect to the Chef server

Find a Chef Server

To work in a corporate environment, your organization needs access to a Chef server.

To learn Chef and test your cookbooks for free, you can create an account on the “hosted” Chef server, maintained by the Chef company. The plan allows five nodes at a time, so you can even launch a small server farm for yourself. Another option is to launch your own Chef server (on-premises) and manage up to 25 nodes on it for free. That could be enough for a small organization to get started with automation. Please see the Chef web portal for more information at https://www.chef.io/

To use the “hosted” Chef server

To launch your own Chef server

Accessing the Chef Server

To access the Chef server you need a user account to log into the web interface and a key to access the server with command line tools, like knife.

Until you set up your workstation to access the Chef server, you will  get the following error message:

WARNING: No knife configuration file found
WARN: Failed to read the private key C:\chef\client.pem: #<Errno::ENOENT: No such file or directory @ rb_sysopen - C:\chef\client.pem>
ERROR: Your private key could not be loaded from C:\chef\client.pem
Check your configuration file and ensure that your private key is readable

Create a user account on the Chef server

Register your username

  • Open the Chef server page in your web browser,
  • Click the Click here to get started! link to create a new account,
  • Enter your name, email address and username you want to use and click the Get Started button. The Chef server will send you an invitation email.

Verify your email address

  • Open the email Chef Notifications sent you and click the long link to verify your email address,
  • On the Email Verification page enter the password you want to use on the Chef server and click the Create User button,

Ask your Chef server administrator to invite you to an organization on the Chef server

The administrator

  • Using a web browser log into the Chef server user interface,
  • In the upper right corner select the organization to invite the user to,
  • On the Administration tab select Users on the left side,
  • Under Users click Invite,
  • Enter the username of the new registered user and click the Invite button

Accept the invite to the organization

  • Using a web browser log into the Chef server user interface,
  • On the Welcome to Chef, page click the Accept Invite button.
  • If you are already logged into the Chef server user interface, the upper right corner will show you the number of invitations you have received. Click the red number, then the message to accept the invitation,
  • Select the checkbox next to the organization you want to be part of and click the Accept button.
  • Click Close to dismiss the message window.

Download your key to access the Chef server

  • Using a web browser log into the Chef server user interface,
  • In the upper right corner click your name and select My Profile,
  • In the lower right click the Reset Key link,
  • Click the Download button to download your private .pem key file.

Save your key, you cannot download it again. When you generate a new key, the prior key will be deleted on the server.

Configure knife

The knife command is used to interact with the Chef server. Before you can connect to the Chef server we need to configure knife

  • Open a Bash window in your home directory: ~ on Mac, C:\Users\YOUR_USER_NAME on Windows
  • Execute
    knife configure
  • Get the Chef server address from your administrator and answer the questions:
    Please enter the chef server URL: https://CHEF_SERVER_URL/organizations/ORGANIZATION_NAME
    Please enter an existing username or clientname for the API: YOUR_USER_NAME
    Overwrite /Users/YOUR_USER_NAME/.chef/credentials?? (Y/N) Y
    
  • Get the chef_shell.rb and knife.rb from your administrator and place them at ~/.chef on Mac and C:\Users\YOUR_USER_NAME\.chef on Windows,
  • Replace the username placeholders with your username.

Save the key files on your workstation

  • Move the .pem Chef server private key file, you have downloaded during the Chef user registration, to the C:/Chef/.chef directory.
  • Get the VALIDATOR_FILE_NAME.pem file from your Chef server administrator and save it in the C:/Chef/.chef directory.

Test the Chef server connectivity

  • Open a Bash window in the folder of the cookbook at C:\Chef\cookbooks\test
  • Execute
knife cookbook list

to see the list of the available cookbooks on the Chef server.

Upload the cookbook to the Chef server

knife cookbook upload COOKBOOK_NAME --freeze

The –freeze option is the most important. It locks the cookbook on the Chef server so we are forced to increment the version before we upload a new version of the cookbook.


Next:

Create an enterprise cookbook in Beginner’s Guide to DevOps Engineering part 5.

Back:

to the Tutorials page

Permission denied message when you try to upload your new repository to GitHub from a Windows computer

If you work on a Windows computer and create a new GitHub repository, you can copy the code from the GitHub page to set the remote address and push the existing code to the GitHub server. You may get the following error message:

$ git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Make sure you have selected the HTTPS button to see the correct lines for Windows.
github-01-create-repo

To change to address of the remote server execute the following
git remote set-url origin https://github.com/.....

DevOps Engineering part 3. – Working with AWS

Personalize your workstation

Set up your account in the AWS console

If you are not an AWS account administrator, ask your AWS account administrator to do the following for you

  • Create an account in AWS
  • Add the account to the appropriate user group
  • Generate a password with a request to change it at the first login
  • Generate an AWS Access Key ID and Secret Key
    • Using your browser log into the AWS console
    • In the upper right corner click your user id
    • In the drop down list select Security Credentials
    • On the left select Users
    • In the user list select you account
    • Select the Security Credentials tab
    • Click the Create Access Key button

AWS Command Line Interface

Install AWS CLI


On Macintosh

  • Open a terminal and execute
    brew install awscli
  • For more instructions visit http://docs.aws.amazon.com/cli/latest/userguide/installing.htm

On Windows

  1. Open a Command Prompt as administrator
  2. Execute
    choco install awscli
  3. Close the command prompt and open a new Git Bash to load the updated PATH environment variable.

or

  1. Download the MSI installer from http://docs.aws.amazon.com/cli/latest/userguide/installing.html#install-msi-on-windows
  2. Execute the downloaded file.
  3. Make sure the AWS CLI is in the PATH
    1. Open the  ~/.bashrec file in a text editor
    2. Add the line if missing
      PATH=$PATH:/c/Program Files/AWSCLI/bin

Configuration

If you do not configure the AWS CLI you will get the following error message: ‘NoneType’ object has no attribute ‘get_frozen_credentials’

  1. Open a new Bash window, so it can find the newly installed AWS CLI
  2. Execute the following command to save your AWS credentials and default region in the ~.aws ( C:\Users\YOUR_USER_NAME\.aws in Windows ) folder.
    aws configure
  3. Answer the questions
    AWS Access Key ID [None]: YOUR AWS KEY
    AWS Secret Access Key [None]: YOUR AWS SECRET KEY
    Default region name [None]: us-east-1
    Default output format [None]: HIT ENTER FOR NONE
    

Close and reopen all open Bash and Command windows to reload the changed Path environment variable.

The configure command created the .aws folder with two files.


On Macintosh

Your AWS configuration folder is located at ~/.aws

Set the permissions on the folder

  • Open a terminal window and execute
    chmod -R 700 ~/.aws
  • The result should be


On Windows

Your AWS configuration folder is located at C:\Users\YOUR_USER_NAME\.aws


Your  credentials file will look like this

[default]
 aws_access_key_id = MY_ACCESS_KEY
 aws_secret_access_key = MY_SECRET_KEY

Test Kitchen will use the keys from the [default] section to connect to AWS when we launch instances.

When you work with multiple AWS accounts you can add all of your keys to the credentials file. To use a specific key, add the profile option to your command line instructions. If you don’t specify the profile in your AWS commands, the AWS Command Line Interface will use the key from the default section.

[aws01]
 aws_access_key_id = MY_ACCESS_KEY_FOR_AWS01
 aws_secret_access_key = MY_SECRET_KEY_FOR_AWS01

[aws02]
 aws_access_key_id = MY_ACCESS_KEY_FOR_AWS02
 aws_secret_access_key = MY_SECRET_KEY_FOR_AWS02

[default]
 aws_access_key_id = MY_ACCESS_KEY_FOR_AWS01
 aws_secret_access_key = MY_SECRET_KEY_FOR_AWS01

The config file will look like this. If you don’t specify the region in the AWS command, the AWS Command Line utility will use the region from this file.

[default]
region = us-east-1

Collect the following information to be able to launch an instance in AWS

  • Your IAM user name
  • AWS Access Key and Secret Key
  • Region (us-east-1)
  • Availability zone (b)
  • VPC subnet ID
  • Security group ID
  • AWS key pair file
  • AMI ID

Create a folder to store your private keys

Keep your private keys in a folder in your home directory. You will need them to launch servers, and log into Linux servers with SSH, or retrieve the administrator password for Windows servers.

On Macintosh

Create the folder ~/aws_keys

Set the permissions on the folder key folder too

  • Open a terminal window and execute
    chmod -R 700 ~/aws_keys
  • The result should be

If you copy key files to the folder you may get the following error message:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0755 for ‘/Users/YOUR_USERNAME/.aws/KEY_FILE_NAME.pem’ are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key “/Users/YOUR_USERNAME/.aws/KEY_FILE_NAME.pem”: bad permissions USERNAME@SERVER_IP’s password: Permission denied, please try again.

To satisfy the security requirements set the permission on the key files to 700

chmod -R 700 ~/.aws/KEY_FILE_NAME.pem

On Windows

Create the folder C:\Users\YOUR_USER_NAME\aws_keys


Generate an AWS key pair

  • Log into the AWS console
  • Select EC2
  • Under Network & Security select Key Pairs
  • In the upper right corner select the region
  • Click the Create Key Pair button
    Create your key pair with the following naming scheme:
    userid_accountname_region
    For example: USERID_aws01_us_east_1
  • Your browser automatically downloads the .pem private key file. Move it to and save it in the ~aws_keys (C:\Users\YOUR_USER_NAME\aws_keys on Windows) directory you created above during the AWS CLI configuration.

For more info visit Amazon EC2 Key Pairs

Set up your .kitchen.yml file

When you have created your cookbook, Chef already added a .kitchen.yml file that tells Test Kitchen how to launch a server instance on your workstation.

The default .kitchen.yml file only contains driver and provisioner information for Vargrant. To launch a server instance in AWS we need to add AWS specific instructions to the file. First modify the .kitchen.yml file to be ready for other drivers:

---
provisioner:
  name: chef_zero

verifier:
  name: inspec

platforms:
  - name: ubuntu-16.04
    driver:
      name: vagrant

  - name: centos-7.2
    driver:
      name: vagrant

suites:
  - name: default
    run_list:
      - recipe[test::default]
    verifier:
      inspec_tests:
        - test/recipes
    attributes:

Make sure the empty lines are really empty. The .kitchen.yml file should not have white space in a seemingly empty line.


Next:

Connect to the Chef server in Beginner’s Guide to DevOps Engineering part 4.

Back:

to the Tutorials page

List the installed Windows Features on the Windows server with PowerShell

When you set up a new Windows server and want to make sure all necessary Windows features are installed on it, you can list them in text format. If you want to replicate the configuration of an existing server, just list the features of both servers and compare them in a comparison tool, like Araxis Merge.

To list the installed Windows features, execute the following in the PowerShell prompt

get-windowsfeature

The result follows the layout of the checkboxes of the graphical user interface in text form.

[X] Web Server (IIS)         Web-Server                 Installed
   [X] Web Server            Web-WebServer              Installed
   [X] Common HTTP           Features Web-Common-Http   Installed
   [X] Default Document      Web-Default-Doc            Installed
   [X] Directory Browsing    Web-Dir-Browsing           Installed
   [X] HTTP Errors           Web-Http-Errors            Installed
   [X] Static Content        Web-Static-Content         Installed
   [X] HTTP Redirection      Web-Http-Redirect          Installed
   [ ] WebDAV Publishing     Web-DAV-Publishing         Available

To produce a simpler output execute

Dism /online /Get-Features

This will return

Deployment Image Servicing and Management tool
Version: 6.3.9600.17031

Image Version: 6.3.9600.17031

Features listing for package : Microsoft-Windows-ServerCore-Package~31bf3856ad364e35~amd64~~6.3.9600.16384

Feature Name : NetFx4ServerFeatures
State : Enabled

Feature Name : NetFx4
State : Enabled

Feature Name : NetFx4Extended-ASPNET45
State : Disabled

Remove Policyfile.rb from your Chef cookbook

When you test your cookbook in Chef Test Kitchen and get the following error, delete the “Policyfile.rb” from your Chef cookbook directory.

$$$$$$ You must set your run_list in your policyfile instead of kitchen config. The run_list your config will be ignored.
$$$$$$ Ignored run_list: ["recipe[...::...]"]
       Preparing dna.json
       Exporting cookbook dependencies from Policyfile /tmp/...
       Error: Invalid lockfile data
       Reason: (ChefDK::DependencyConflict) Cookbook ... (...) has dependency constraints that cannot be met by the existing cookbook set:
       Cookbook ... isn't included in the existing cookbook set.

Chef Data Bags

Create an encrypted Chef data bag

There are secrets in most of the Chef cookbooks that we want to protect. We don’t want to give out user names, passwords and AWS keys.  In Chef the best place to hide these secrets is the Encrypted Data Bag.

A Data Bag is a JSON file that we can encrypt, so we can store it in version control with the rest of the cookbook.

To make  continuous integration and delivery (CI/CD) easier, store the Encrypted Data Bags in the cookbook folder structure and commit them together with the rest of the cookbook into version control (Git)

To make sure the unencrypted secret is not committed into version control, add the following line to the  .gitignore file

# Ignore the unencrypted Data Bags
data_bags_unencrypted/

The structure of Chef folder should look like this. Store the unencrypted Data Bags with the original values in the data_bags_unencrypted folder

Create a folder for the unencrypted Data Bag and create a file for the Data Bag Item. The name of the file and the value of the id element should be the same.

Enter the Data Bag Item values and save the file.

{
 "id": "access_key",
 "AccessKey": "XXXXX",
 "SecretKey": "YYYYY"
}

Automate the data bag encryption

Create the folder structure

  1. Create a folder for data bag related files on the same level as the cookbooks folder. Name it data_bags

  2. Get the data bag encryption secret file from your Chef server administrator and place it in the data_bags_unencrypted  folder.
  3. Create a folder for Chef related scripts on the same level as the cookbooks folder. Name it devops-chef-scripts

Create the automation script

Create the following script and name it encrypt_databag.sh. This script

  1. Encrypts the Data Bag,
  2. Uploads the encrypted data bag to the Chef server,
  3. Saves the encrypted data bag in the data_bags folder on your workstation.

Replace >>>MY_ENCRYPTED_DATABAG_SECRET<<< with the name of the encrypted data bag secret file.

#!/bin/bash
if [ -z $1 ] || [ -z $2 ]
then
	echo "Please supply the arguments: DATABAG_NAME ITEM_NAME"
	echo "../devops-chef-scripts/encrypt_databag.sh [DATA_BAG_NAME/NAME OF THE FOLDER] [ITEM_NAME/ID]"
else

  echo -- knife data bag create $1
  knife data bag create $1

  # Encrypt the databag and upload it to the Chef server
  echo -- knife data bag from file $1 $1/$2.json --secret-file ../data_bags_unencrypted/>>>MY_ENCRYPTED_DATABAG_SECRET<<<
  knife data bag from file $1 $1/$2.json --secret-file ../data_bags_unencrypted/>>>MY_ENCRYPTED_DATABAG_SECRET<<<

  # Create a directory for the encrypted databag on the workstation
  echo -- mkdir -p ../data_bags/$1
  mkdir -p ../data_bags/$1

  # Download the encrypted data bag
  echo -- knife data bag show $1 $2 -F json 'to' ../data_bags/$1/$2.json
  knife data bag show $1 $2 -F json > ../data_bags/$1/$2.json

  echo "Encrypted data bag has been created at ../data_bags/"$1"/"$2".json"

fi

echo -n "Press a key to exit"	#'-n' means do not add \n to end of string
read              		# No arg means dump next line of input

Add execution right to the file

chmod +x ./encrypt_databag.sh

Encrypt the data bag

Open a Bash window in the data_bags_unencrypted folder

Execute the following command, where

DATA_BAG_NAME is the name of the data bag folder
ITEM_NAME is the value of the id element and the item file name without the ‘.json’ extension,

../devops-chef-scripts/encrypt_databag.sh DATA_BAG_NAME ITEM_NAME

The script will create a folder for the Data Bag in the “data_bags” folder and save the encrypted Data Bag file in it.

The following warning is normal. We did not want to unencrypt the data bag, just download the encrypted version.

WARNING: Encrypted data bag detected, but no secret provided for decoding. Displaying encrypted data.

Troubleshooting

If you get the error message

ERROR: The object you are looking for could not be found
Response: Cannot load data bag item … for data bag …

make sure you set the name of the data bag item file without the .json extension and the value of the id element the same.

 

Unable to satisfy the following requirements error message in Chef Test Kitchen

When Berkshelf in the Chef Test Kitchen cannot resolve the cookbook dependencies, it displays the following error message during converge:

Unable to satisfy the following requirements

To help Berks to start a fresh calculation, delete the Berksfile.lock file and enter the following into the command window:

berks install

DevOps Engineering part 2. – Create and test your first cookbook in 5 minutes

In the first part of the series, Beginner’s Guide to DevOps Engineering Part 1. we have already installed the DevOps development tools.

Create and test your first cookbook in 5 minutes

 Set up the Chef working folder

  1. Create a folder for the Chef development
    1. on Mac ~/Chef
    2. on Windows C:\Chef
  2. In the Chef folder create a sub-folder cookbooks
  3. Right-click the cookbooks folder
    1. on Mac select Services, iTerm2 in Finder
    2. on Windows  select Git Bash Here

Create your first cookbook

    • Enter the following command into the Bash window to create a new cookbook
      chef generate cookbook test

Specify the program you want to use to open .rb files

on Mac

  1. In Finder navigate to ~/Chef/test/recipes
  2. Right-click the default.rb file and select Open With, Atom

on Windows

  • In File Explorer navigate to the C:\Chef\test\recipes older
  • Right-click the default.rb file
    • Select Open with
    • Select the Always use… checkbox  and click the More apps link
  • Select Notepad++ and click the OK button

 

Let’s create a file with Hello world in it.

      • Enter the following to create your first recipe
        • on Mac
          file '/Users/YOUR_USERNAME/Desktop/helloworld.txt' do
           content 'Hello world'
          end
        • on Windows (make sure you use double backslashes!!!)
          file 'C:\\Users\\YOUR_USERNAME\\Desktop\\helloworld.txt' do
           content 'Hello world'
          end
      • Save the file
      • In the bash Window navigate to the test cookbook directory
        cd test
      • Execute your first recipe with the following in the Bash window
        chef-client --local-mode recipes/default.rb
      • Navigate to the Desktop and open the helloworld.txt file to see the result of your script.

Test your cookbook on a virtual machine

We will use Test Kitchen and Vagrant to launch virtual machines. Currently, only Linux images are available for Vagrant, so we will modify our recipe to select between Linux and Windows and act accordingly.

Open the default.rb recipe and update it to look like this

case node['os']
when 'linux'
  file "/tmp/helloworld.txt" do
    content 'This file was created by Chef!'
  end
when 'windows'
  file "C:\\Chef\\helloworld.txt" do
    content 'This file was created by Chef!'
  end
end

Enter the following commands into the Bash window

      • Display the available test configurations ( suites )
        kitchen list
      • Launch a virtual Linux machine and test your recipe
        kitchen converge ubuntu

        The first time you launch a virtual machine with an operating system you have never used on your workstation, Vagrant has to download the machine image from the Internet. It can take 5-10 minutes. When the virtual machine is created and launched, Test Kitchen will copy your cookbook to it and execute it there.
      • Test kitchen will display the —–> Kitchen is finished message when the cookbook has successfully executed.
      • Log into the virtual machine
        kichen login ubuntu
      • The root prompt appears in the Bash windows. Let’s check if the file has been created or not.
      • To destroy the virtual machine
        kitchen destroy ubuntu

Windows in Vagrant

To test your cookbook on a Windows virtual machine locally, create one for Vagrant. See Launch Windows instances locally with Chef Test Kitchen for the details.

Learn the basics, so you can ask questions

Chef has a steep learning curve. Chef is not just scripting or programming, but you have to understand how Chef works to be able to use it to configure servers. There are many ways to do the same thing and there is not much documentation to recommend the best way. If you search Google, the problems usually have multiple solutions, and many times the “best” answer is selected based on personal preference. To get started, you should familiarize yourself with the tools, because you will use most of them during the development process.

In this guide I will use a Windows computer as a workstation, but all tools work on Mac and Linux computers.

Vagrant

Learn Vagrant to understand how Test Kitchen manages the test servers on your local machine or at AWS. You will not use vagrant directly, but Test Kitchen uses it to launch servers.

Chef

Test Kitchen

Ruby

Terraform


Next:

Working with AWS in Beginner’s Guide to DevOps Engineering part 3.

Back:

to the Tutorials page

Beginner’s Guide to DevOps Engineering part 1.

DevOps engineering (Release engineering) is a relatively new profession. There is a very high demand for experienced DevOps engineers, because more and more large corporations want to migrate their data centers into the Cloud. In this series I will introduce you to the tools of the trade through the development of a Chef cookbook.

The tools of the DevOps engineers are new and most of them are in the active development phase with frequent releases. Some of the new versions have show stopping bugs in them, so it is a good idea to test all new versions of the tools before you uninstall the old one.

To work as a DevOps engineer you need a development environment with multiple tools. Luckily all of them are available for free and easy to set up.

  • The Chef Development Kit to write and test your Chef cookbooks and recipes,
  • Vagrant, the orchestrator, to contain the virtual machines to test the scripts,
  • Virtual Box to launch the virtual machines,
  • Chef needs Ruby to run,
  • Git, the version control system.

You can do all development and testing on your workstation for free, but to see your scripts running in a real cloud, you can set up an account at a cloud provider. Amazon Web Services (AWS) offers a free tier where you can launch small server instances for free.

In this guide I will use a Windows computer as a workstation, but all tools work on Mac and Linux computers.

Install the DevOps development tools on Windows

Set up your computer

Windows

Display the file extensions

In Windows 10
  • Open Windows explorer
  • On the View tab select
    • File name extensions
    • Hidden items
      windows-03-show-file-extensions
In Windows 7
  • Open Windows Explorer and select Organize
  • Select Folder and search options
    windows-02-show-file-extensions
  • On the View tab
    • Select Show hidden files, folders, and drives
    • Uncheck Hide extensions for known file types
      windows-01-show-file-extensions

 

Macintosh

Apple Id

If you don’t have an Apple ID create one. You can obtain one without a credit card:

  • Start iTunes on your Macintosh,
  • Click the drop down menu in the upper right corner,
    apple-id-01
  • If Apps is visible, select it, otherwise click Edit Menu…
    • Select Apps to display it in the drop down.
      apple-id-02
  • Search for a free app in the App Store and start to download it,
    apple-id-03
  • Create a new Apple Id and select None for credit card type.

Show the user home directory

  • Open Finder
  • In the Finder menu select Preferences
  • In the Favorites section select the checkbox next to your user name
    show-home-directory

Create a directory for optional applications

Create the opt folder in the root of the harddisk.

Remote Desktop Client

Windows

The Windows operating system already has a Remote Desktop Client

Macintosh

Download the Microsoft Remote Desktop app from the App Store

  • Open the App Store
  • Search for “microsoft remote desktop”
  • Click the Microsoft Remote Desktop icon
  • Click the blue Get button
  • Click the green Install App button

Text Editor

Windows

Notepad ++

Install a good text editor. If you do not have a favorite, I recommend Notepad ++

Configure Notepad ++

Tab settings

  • In the Settings menu select Preferences
  • In the Tab Settings section set the Tab size to 2 and select Replace by space
    tab-settings-01

Macintosh

Atom

  • Download it from https://atom.io/
  • Double click the downloaded ZIP file to extract the application,
  • Drag the Atom application into Applications

Terminal Window

Macintosh

Install iTerm2, a smart terminal emulator to issue Bash commands and log into Linux servers.

Configuration suggestions are at

https://ruigomes.me/blog/perfect-iterm-osx-terminal-installation/
https://gist.github.com/kevin-smets/8568070

Enable unlimited scroll back

  • Start iTerm2 and open the preferences window by pressing ⌘, (command-comma)
  • On the Terminal tab click the Unlimited scrollback check box.

Git

Windows

  • Navigate to https://git-scm.com/download/win to download Git for Windows. The page automatically downloads the installer for the operating system you use.
  • Install the application
  • Accept the default values, including these:
    • Make sure the Windows Explorer integration for Git Bash is checked.
      git-for-windows-01-intergration
    • Enable the Git tools in the command prompt too
      git-for-windows-02-command-prompt
    • Line endings for Windows computers
      git-for-windows-03-line-endings
    • Terminal emulator
      git-for-windows-04-terminal
    • Caching
      git-for-windows-05-caching
    • Finish the installation
      git-for-windows-05-finish

Configure Git for Windows

Enable Page Up and Page Down

  • In Windows Explorer right click in the white area and select Git Bash Here,
  • Stretch the Bash window to the full width of the page to have more room to work later,
  • Right click the Bash window and select Options…,
  • On the Window tab,
    • Click the Current size button to save the size,
    • Select PgUp and PgDn scroll without modifier to be able to scroll quickly up and down in the window with the Page up and Page down buttons.
      bash-04-window

Set up Git Bash to always run as Administratort

Certain commands need elevated rights to run, so we will set up the Bash window to run as administrator.

  • In Windows 7 click the Windows Start button and type bash
    bash-01-admin
  • Right click the found link and select Properties
    bash-02-admin
  • On the Compatibility tab select Run this program as administrator
    bash-03-admin

Macintosh

  • Navigate to https://git-scm.com/download/mac to download Git for Windows. The page automatically downloads the installer for the operating system you use.
  • This app is not trusted by Apple, so to install it
    • Control-click the downloaded file and select Open
    • Click the Open button to confirm the action

Virtual Box

Download Virtual Box from https://www.virtualbox.org/wiki/Downloads and follow the instructions to install it.

At the time of writing this was the section where the installer files were referenced

virtual-box-01-download

Run the downloaded installer file and accept all default values.

The installer starts the application. You can close it, we will use other tools to start it in the future.

Vagrant

Windows and Macintosh

Important

The default credentials of a Vagrant server are:

  • UserName: vagrant
  • Password: vagrant

Ruby

Windows

  • Download Ruby from http://rubyinstaller.org/downloads
  • Install the 32 bit version, as the 64 bit version is fairly new and has compatibility issues. Download the latest Ruby installer. Pick the file that does not have the (x64) at the end.
  • Accept the default values but check Add Ruby executables to your PATH
    ruby-01-add-to-path

 Ruby Development Kit

The Ruby Development Kit is need for certain Ruby gems, so install it.

  • Download the Ruby Development Kit from the DEVELOPMENT KIT section of  http://rubyinstaller.org/downloads
  • If you have installed the 32 bit version of Ruby make sure you install the 32 bit version of the DevKit. Select the Development kit that matches the Ruby version you installed. At the time of writing the latest development kit is under “For use with Ruby 2.0 and above (32bits version only)
    • Run the installer to extract it to a permanent location (C:\RubyDevKit)
    • Open a command window in the C:\RubyDevKit folder
    • Run these commands in the command prompt to install it.
      • ruby dk.rb init
      • ruby dk.rb install
  • For more information see  http://github.com/oneclick/rubyinstaller/wiki/Development-Kit

Macintosh

Ruby is already a part of the operating system.

Chef Development Kit

Windows and Macintosh

Terraform by Hashicorp

Windows installation

  • Unzip the downloaded package to C:\HashiCorp\Terraform
  • Add the Terraform directory to the path of the computer. It is not added automatically on 64 bit Windows.
    • In Windows Explorer right click Computer and select Properties,
    • On the left side select Advanced System Settings,
    • At the bottom click the Environment Variables… button,
    • In the System Variables box select Path and click the Edit… button,
    • Add the following to the end of the Variable value. (Don’t forget to start with the semicolon as the separator).
      ;C:\HashiCorp\Terraform
  • To create RDS (Relational Database Service) instances in AWS, install the Amazon Web Services Command Line Interface (See instructions below)
  • Configure the GitBash window to run as administrator to be able to execute the “terraform get” command to get local modules during development
    • Right click the shortcut of the Bash window you use and select Properties
    • On the Compatibility tab check Run this program as an administrator

For more details see https://www.terraform.io/intro/getting-started/install.html

Macintosh installation

  • Download Terraform from https://www.terraform.io/downloads.html
  • Double click the downloaded ZIP file to extract the application
  • Create a directory, terraform for the Terraform application in the /opt folder
  • Move the Terraform application into the terraform directoryin the /opt folder
  • Add the location to the path
    • Open the terminal iTerm2 window
    • Navigate to the home directory
      cd ~
    • Find out if the Bash Profile file exists
      ls .bash_profile
    • If the result is ls: .bash_profile: No such file or directory
      • Create the Bash Profile file.
      • Add the following lines
        # PATH Export
        PATH=/opt/terraform:$PATH
        export PATH
        unset DYLD_LIBRARY_PATH
        

Graphviz – Dependency Graph Visualization Software

We will use this utility to display the Terraform graphs.

  • Download from http://www.graphviz.org/Download..php
    There are really two dots in the address :-)
  • Execute the installer
  • You may need to add the location to the Path environment variable. Make sure you use the actual folder name, as it contains the version of the application.
    ;C:\Program Files (x86)\GraphvizX.XX\bin


Next:

Set up the DevOps development environment in Beginner’s Guide to DevOps Engineering part 2.

Back:

to the Tutorials page