Ansible Tutorial – Introduction and Lab Setup

What is Virtualization?

  • Multiple OSes on a single machine
  • Giving an illusion that each OS is running on real HW
  • Virtual Machine Monitor (VMM)
  • Another layer of kernel to virtualize multiple OSes
  • Also called “hypervisor”

Virtualization and Cloud Computing

  • Virtualization is the ability to run “virtual machines” on top of a hypervisor
  • A hypervisor provides a uniform abstraction of the underlying physical machine.
  • Abstraction is the key idea in Service Models of Cloud!
  • Virtualization can make 1 resource act like many, while cloud computing lets different departments (through private cloud) or companies (through a public cloud) access a single pool of automatically provisioned resources.

Type-1 vs Type-2 Virtualization

  • Depending on what sits right on HW

Type-1: VMM on HW Type-2: Host OS on HW
VMWare – ESX VMWare Workstation
Microsoft – HyperV Oracle – VirtualBox
Oracle OVM
IBM PowerVM
Linux – KVM

Virtualization Vs. Cloud Technology

Virtualization Cloud
Definition Technology Methodology
Purpose Create multiple simulated environments from 1 physical hardware system Pool and automate virtual resources for on-demand use
Use Deliver packaged resources to specific users for a specific purpose Deliver variable resources to groups of users for a variety of purposes
Configuration Image-based Template-based
Cost High capital expenditures (CAPEX), low operating expenses (OPEX) Private cloud: High CAPEX, low OPEX
Public cloud: Low CAPEX, high OPEX
Scalability Scale up Scale out

Oracle VM Virtual Box

  • Oracle VM VirtualBox is cross-platform virtualization software that allows users to extend their existing computer to run multiple operating systems at the same time.
  • Designed for IT professionals and developers, Oracle VM VirtualBox runs on Microsoft Windows, Mac OS X, Linux, and Oracle Solaris systems and is ideal for testing, developing, demonstrating, and deploying solutions across multiple platforms on one machine.

Virtual Network Switches

  • This is a simple software construction on a host server, that your virtual machines “plug in” to, and direct their traffic through.
  • On a Linux host server, the virtual network switch shows up as a network interface

Network Address Translation (NAT)

  • Any guests connected through it, use the host IP address for communication to the outside world.
  • Computers external to the host can’t initiate communications to the guests inside, when the virtual network switch is operating in NAT mode.

Use of NAT mode

  • It can be used anywhere where there is no need for ‘being seen on the network’.
  • For instance, a web developer who optimizes web pages for different operating systems and web browsers.
  • Or any other developer, who need to try things out in different configurations, environments, or operating systems.

SSH and Connectivity

  • SSH – Secure Shell
  • A Network Protocol that allow to access a Server from a client.
  • Putty/ Terminal etc
  • When using a Command Line tool to perform SSH connectivity
  • It is not encrypted and hence not secure, especially on public network
  • Network Sniffers can open packets
  • Using Packet Analysis

SSH Keys

  • SSH KEYs are based on Public Key Cryptography
  • A Cryptographic network Protocol used over an Unsecure Network
  • Provides a Secure Channel over an Unsecure / Public Network
  • An SSH KEY is a Key Pair (2 Keys)
  • Public Key – sent to server to be authenticated.
  • Private Key – kept at the client.
  • Tools to Create SSH Keys
  • Windows – Puttygen (www.putty.org)
  • Unix / Linux – ssh-keygen command

SSH Configuration Commands

sshd   The daemon service; this must be running to receive inbound Secure Shell client requests.

ssh   Secure Shell command, ssh. To make it work with key-based authentication, you need a private key on the client and a public key on the server. Copy the public key file (e.g. id_rsa.pub) to ~/.ssh/authorized_keys of user.

ssh-keygen   A utility that creates private/public key pairs for SSH authentication. The ssh-keygen -t keytype will create a key pair based on the DSA, ECDSA, or RSA protocol.

ssh-copy-id   A script that copies a public key to a target remote system.

SSH Client Configuration Files

  • Systems configured with SSH include configuration files in two different directories.
  • For the local system, basic SSH configuration files are stored in the /etc/ssh directory.
  • The configuration files in each user’s home directory under ~/.ssh/.
  • Those files configure how the given user is allowed to connect to remote systems.
  • When RSA keys are included, ~/.ssh/ subdirectory includes these files:

authorized_keys Includes a list of public keys from remote users. The system users and names are listed at the end of each public key copied to this file.

id_rsa Includes the local private key based on the RSA algorithm.

id_rsa.pub Includes the local public key for the user based on the RSA algorithm.

known_hosts Contains the public host keys from remote systems.

  • The first time a user logs in to a system, he’s prompted to accept the public key of the remote server.
  • The corresponding public key on the remote server is added by the client to its local ~/.ssh/known_hosts file.

Setup a Linux Virtual Machines and Host only Adaptor

You need at least two Linux Machines for the Ansible tutorial. You also need to create ssh keys for key based authentication.

Two Oracle Linux VMs are already created for you and available for download. First VM is server, a GUI based machine and second is tester1, without GUI.

Objectives:

  • Download and Install Oracle VM Virtualbox.
  • Configure Host Only Adaptor on VirtualBox.
  • Import VMs provided by Instructor
  • Configure both machines to use Host only Adaptor and configure networking between them.

Pre-Requisite

  • Two VMs images downloaded as per instruction given from

https://oci-cli.s3.amazonaws.com/server.ova

https://oci-cli.s3.amazonaws.com/tester1.ova

  • At least 50GB Space on your Host machine
  • Virtualization Enabled on BIOS Settings of Host Machine
  • Any existing Hypervisor (such as HyperV on Windows) disabled.

Sequence 1. Install Oracle VM Virtual Box and Configure a Host Only adaptor.

  1. Download and install VirtualBox from www.virtualbox.org. This lab assumes you are using VirtualBox 6.1.12.

  1. Set preferences for storing your VM files. This depend on the Disk Space you have on your computer. You will need about 30 GB of Space to import the VM Images for this training. To set the preference, click on Preferences (icon) in VirtualBox

  1. In the General Tab of the Preferences screen, choose the Directory in which you want to create the VM related files. Click Ok to close the Preferences screen.
  2. Launch Oracle VM virtual Box and open File -> Host Network Manager

 

  1. If Oracle VM Virtual box is already installed, you may have an existing Host only Adaptor. Don’t change that. Create a new one for this training. For this, click on Create You may get a warning on permission. Accept that warning and you will see the adaptor is added as screenshot given

 

  1. The adaptor name and other details are selected by default. Click on Properties and Fill/Change IP Address to “10.10.0.1” as given below:

 

Take note of the Adaptor Name. You will need to enable the same in the VM for networking.

  1. Slick on the Second Tab “DHCP Server” and Change details to
  • Check Box, Enable Server: Checked
  • Server Address: 10.10.0.2
  • Server Mask: 255.255.255.0
  • Lower Address bound: 10.10.0.100
  • Upper Address bound: 10.10.0.200

It should be same as screen shot given below.

  1. Click on Apply. You may get a warning. Accept the warning and Close the dialog box. You should see the Adaptor Details Changed as given below

  1. Host Network Adaptor is added now.

Sequence 2. Download and Import Virtual Machine

    1. Download the VMs from the given URL.
    2. To import the downloaded VM Images select File – > Import Appliance
    3. You will get a pop up in which you need to specify the location of the VM Image.
    1. Click on the Folder Option available at the end of the Text Box and select the downloaded VM Image, server.ova.
    1. Click Open. In the resulting screen click Next.
    1. In the Next Screen, select Include All Network Adaptor MAC addresses under MAC Address policy.
    2. Click on Import

If you don’t see the Guest OS Type as Oracle (64-bit), just check in the BIOS of your computer and ensure VT is enabled for the CPU.

You need to shut down and boot your computer and use the F2/F8 key to get to the BIOS options. The Function Key can vary from computer to computer.

It is also required that no other Hypervisor/Docker based software (e.g HyperV on Windows) is enabled on your Computer, you need to disable it so that Virtual Box can use the Virtualization features of your computer.

    1. Once the VM Image is imported, the VM is available and listed in VirtualBox.

    1. Click on the VM and Click on the Start Button in VirtualBox window.

If the machine fails to start, ensure that:

  1. You have latest Virtual Box extension pack installed for your operating system. If not installed already, download it from

https://download.virtualbox.org/virtualbox/6.1.12/Oracle_VM_VirtualBox_Extension_Pack-6.1.12.vbox-extpack

  1. You have at least 50GB space free on your system.
  2. Hyper-V is disabled on Windows system.
  3. Intel VM technology/Virtualization is enabled in Bios.
  4. Once the VM boots up, enter the username and password to login.

Username – oracle

Password – oracle

  1. Similarly Import the Second VM tester1

You can do all the practices related to OCI CLI, Ansible, Docker and Kubernetes on these Linux VMs, so that you don’t need to transfer the files between your VM and Laptop.

  1. You need to ensure your Linux VM has internet Access. For that, open the Firefox browser (Applications -> Firefox) and enter a website such as theskillpedia.com and check you are able to access the website.

You may have to enter proxy setting in Firefox if you are behind a proxy server. If required specify it by clicking the 3 line menu on the Top Right in your Firefox browser, click on Preferences.

    1. In the preferences tab, click on Advanced
    2. In the Advanced Tab, click on Network
    3. Click on Settings for Connection.
    4. In the Settings page, specify the proxy settings as required on your network to access the internet and again verify from the browser if you are able to access the internet.
    5. Right Click on the First Machine, server, and Click on Settings to open settings dialog box. Click on Network. It should show the dialogue as given below

  1. Click on Second Tab. Ensure that checkbox “Enable Network Adaptor” is checked and from Attached to drop down list select “Host only Adaptor”. Your adaptor added will automatically appear in Name drop down list. Refer the Screen shot below.

  1. Click OK to close the dialog box.
  2. Follow the steps 12, 13 and 14 for the second machine tester1.
  3. Now Host Adaptor is configured for both machines. This will help you in setting networking between VMs.
August 5, 2020
Designed by  © Alliance Softech Pvt Ltd. All rights reserved.
WhatsApp chat
X