Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 29 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,87 +14,56 @@ This project offers environment for all the labs in **Red Hat RHCSA/RHCE 7 Cert
- [Vagrant](https://www.vagrantup.com): tool for building complete development environments. With an easy-to-use workflow and focus on automation

Don't worry you don't have to be expert on any of these tools.
### 1. Install virtualbox :

**1.1 Install virtualbox on Ubuntu:**
Follow the individual instructions for your platform:
- RHEL/Centos 7 with [VirtualBox](rhel-centos7-vbx.md) or [KVM](rhel-centos7-kvm.md)
- [Fedora](fedora-vbx.md)
- macOS TODO
- [Ubuntu](ubuntu.md)
- Windows TODO

```shell
$ wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox_2016.asc | sudo apt-key add -

$ sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian `lsb_release -sc` non-free contrib" > /etc/apt/sources.list.d/virtualbox.org.list'

$ sudo apt-get update

$ sudo apt-get install dkms

$ sudo apt-get install virtualbox-5.1
```
**1.2 Install virtualbox on Oracle Linux/RHEL/CentOS:**
```shell
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -

$ sudo wget http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo

$ sudo yum install VirtualBox-5.1
```

**1.3 Install virtualbox on Fedora:**
## Download (clone) lab environment from GitHub
```shell
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -

$ sudo wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo

$ sudo yum install VirtualBox-5.1
cd ~
git clone https://github.com/AnwarYagoub/RHCSA-RHCE-Lab-Environment.git
cd ~/RHCSA-RHCE-Lab-Environment
```
### 2. Install vagrant :

**2.1 Install vagrant on Debian-based Linux Ubuntu/Mint (64-bit):**
If your distribution runs without GUI, then execute these 2 commands:
```shell
$ wget https://releases.hashicorp.com/vagrant/1.8.7/vagrant_1.8.7_x86_64.deb

$ sudo dpkg -i vagrant_1.8.6_i686.deb
sed -i 's/gui\: true/gui\: false/g' provisioning/RHCSA_RHCE_LAB/defaults/main.yml # no need for gui on commandline
sed -i 's/vb.gui = true/vb.gui = false/g' Vagrantfile # without GUI vagrant will error with 'vb.gui = true'
```

**2.2 Install vagrant on Debian-based distributions Ubuntu/Mint (32-bit):**
```shell
$ wget https://releases.hashicorp.com/vagrant/1.8.7/vagrant_1.8.7_i686.deb

$ sudo dpkg -i vagrant_1.8.6_i686.deb
```

**2.3 Install vagrant on RedHat-based distributions (64-bit):**
```shell
$ sudo yum -y install https://releases.hashicorp.com/vagrant/1.8.7/vagrant_1.8.7_x86_64.rpm
```
## How to start servers?
Navigate to project path where Vagrantfile exists.

**2.4 Install vagrant on RedHat-based distributions (32-bit):**
- setup all servers
```shell
$ sudo yum -y install https://releases.hashicorp.com/vagrant/1.8.7/vagrant_1.8.7_i686.rpm
cd ~/RHCSA-RHCE-Lab-Environment
vagrant up # create all machines, may take 10-60 minutes
ssh-keygen -R 192.168.4.200; ssh-copy-id root@192.168.4.200
ssh-keygen -R 192.168.4.210; ssh-copy-id root@192.168.4.210
ssh-keygen -R 192.168.4.220; ssh-copy-id root@192.168.4.220
vagrant halt # shutdown all machines
vagrant status # all 4 have state poweroff
vagrant snapshot save begin # create a VM snapshot

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is nice that you added a snapshot part

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, in case of errors you can give it a clean start. Should also work on platforms other than Virtualbox.

Sander sometimes assumes changes made in previous chapters, sometimes he doesn't. IMHO a candidate RHCSA should be able to make a small script or flip back a few pages, to get on the same page were Sander assumes you are.

```

## Get environment
```shell
$ git clone https://github.com/AnwarYagoub/RHCSA-RHCE-Lab-Environment.git

$ cd RHCSA-RHCE-Lab-Environment
```
## How to start servers?
Navigate to project path where Vagranfile exists.

- start all servers
```shell
$ vagrant up
vagrant snapshot restore begin --no-provision
```

- start a specific server
```shell
$ vagrant up MACHINE_NAME
vagrant snapshot restore MACHINE_NAME begin --no-provision
```
replace **MACHINE_NAME** with any of (server1, server2, cache-server, labipa)
```shell
$ vagrant up server1
```

## How to access servers?
Navigate to project path where Vagranfile exists.
Navigate to project path where Vagrantfile exists.

- to get shell access to any of environment servers
```shell
Expand Down
61 changes: 61 additions & 0 deletions fedora-vbx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
### Install Vagrant using VirtualBox on Fedora 25

Tested for Fedora 25

Run the following commands on fresh installed Fedora first:
```shell
# Upgrade fedora
sudo dnf -y update # upgrade to the latest kernel etc.

# Install vim editor
sudo dnf -y install vim

# Reboot machine
sudo reboot
```

Have you run `dnf update` lately, then start here:
```shell
# Generate SSH key to use when accessing machines
ssh-keygen -t rsa -b 4096 -N "" -C "root@example.com" -f ~/.ssh/rhce # empty password

# Make loading SSH key to ssh agent automatic
eval $(ssh-agent); echo $'eval $(ssh-agent)' >> ~/.bash_profile
ssh-add ~/.ssh/rhce; echo $'ssh-add ~/.ssh/rhce' >> ~/.bash_profile

# Download VritualBox repository
sudo wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo

# Clean repository cache & import GPG Key
sudo dnf clean dbcache
sudo dnf -y repolist # Import the GPG keys

# Install lastest virtualbox; will error when multiple versions of virtualbox are offered.
sudo dnf -y install git gcc make kernel-devel VirtualBox*

# Install VirtualBox kernel modules
sudo /sbin/vboxconfig # load the vboxdrv kernel module, will fail without dnf update

# Check if vboxdrv service is started without errors
systemctl status vboxdrv # active?

# Check VirtualBox version
VBoxManage --version # should return no errors

# Restart machine
sudo reboot
```

```shell
# Get latest vagrant version
# which of the following 3 is easiest to maintain and has most chance to fail gracefully when content or url change?
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | sed -nr '/.*href="\/vagrant\/([^/]*).*/{s//\1/p;q}' ` # from top of page
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | awk 'match($0, /href="\/vagrant\/([^/]*)/, a) {print a[1]; exit}'` # pick top version listed on page
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | awk 'match($0, /href="\/vagrant\/([^/]*)/, a) {if (RSTART) { ++i; v[i]=a[1]}} END {n = asort (v); print v[n]}'`

# Install vagrant
sudo dnf -y install https://releases.hashicorp.com/vagrant/"$vagrant_version"/vagrant_"$vagrant_version"_x86_64.rpm

# Check vagrant version
vagrant --version
```
23 changes: 23 additions & 0 deletions rhel-centos7-kvm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### Install Vagrant using KVM on RHEL/CentOS 64-bit

Tested on CentOS 7.3 1610-01. Vagrantfile *not* tested with KVM.

```shell
# Generate SSH key to use when accessing machines
ssh-keygen -t rsa -b 4096 -N "" -C "root@example.com" -f ~/.ssh/rhce # empty password

# Make loading SSH key to ssh agent automatic
eval $(ssh-agent); echo $'eval $(ssh-agent)' >> ~/.bash_profile
ssh-add ~/.ssh/rhce; echo $'ssh-add ~/.ssh/rhce' >> ~/.bash_profile

# Get latest vagrant version
# which of the following 3 is easiest to maintain and has most chance to fail gracefully when content or url change?
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | sed -nr '/.*href="\/vagrant\/([^/]*).*/{s//\1/p;q}' ` # from top of page
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | awk 'match($0, /href="\/vagrant\/([^/]*)/, a) {print a[1]; exit}'` # pick top version listed on page
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | awk 'match($0, /href="\/vagrant\/([^/]*)/, a) {if (RSTART) { ++i; v[i]=a[1]}} END {n = asort (v); print v[n]}'`
# Install packages
sudo yum -y install https://releases.hashicorp.com/vagrant/"$vagrant_version"/vagrant_"$vagrant_version"_x86_64.rpm git qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm

# Install vagrant libvirt plugin
vagrant plugin install vagrant-libvirt ; echo $'vagrant plugin install vagrant-libvirt'>> ~/.bash_profile
```
48 changes: 48 additions & 0 deletions rhel-centos7-vbx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
### Install Vagrant using VirtualBox on RHEL/CentOS 64-bit

Tested on CentOS 7.3 1610-01

```shell
# Download VirtualBox repository
sudo wget http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo

# Clean repository cache & import GPG Key
sudo yum clean dbcache; sudo yum -y repolist # Import the GPG keys

# Ensure latest version of Extra Packages for Enterprise Linux is installed
sudo yum -y install epel-release # should be 7.8

# Get latest VirtualBox version
# which of the following 2 is easiest to maintain, has most chance to fail gracefully when yum implementation changes or Vbox gets new numbering scheme
export virtualbox_version=`yum -y search VirtualBox | awk 'match($0, /(VirtualBox-[0-9]\.[0-9])/, a) {b=a[1]} END {print b}'` # depends on yum sorting
export virtualbox_version=`yum -y search VirtualBox | awk 'match($0, /(VirtualBox-[0-9]\.[0-9])/, a) {if (RSTART) { ++i; v[i]=a[1]}} END {n = asort (v); print v[n]}'`

# Install packages
sudo yum -y install git gcc make kernel-devel $virtualbox_version

# Install VirtualBox kernel modules
sudo /sbin/vboxconfig # load the vboxdrv kernel module

# Check if vboxdrv service is started without errors
systemctl status vboxdrv # enabled?

# Check VirtualBox version
VBoxManage --version # should return no errors

# Restart machine
sudo reboot
```

```shell
# Get latest vagrant version
# which of the following 3 is easiest to maintain and has most chance to fail gracefully when content or url change?
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | sed -nr '/.*href="\/vagrant\/([^/]*).*/{s//\1/p;q}' ` # from top of page
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | awk 'match($0, /href="\/vagrant\/([^/]*)/, a) {print a[1]; exit}'` # pick top version listed on page
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | awk 'match($0, /href="\/vagrant\/([^/]*)/, a) {if (RSTART) { ++i; v[i]=a[1]}} END {n = asort (v); print v[n]}'`

# Install vagrant
sudo yum -y install https://releases.hashicorp.com/vagrant/"$vagrant_version"/vagrant_"$vagrant_version"_x86_64.rpm

# Check vagrant version
vagrant --version
```
42 changes: 42 additions & 0 deletions ubuntu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
### Instructions for installing VirtualBox & Vagrant on Ubuntu

Tested on Ubuntu 16.04

```shell
# Update packages list
sudo apt update

# Upgrade Ubuntu & cleanup
sudo apt -y upgrade; sudo apt -y autoremove

# Reboot machine
sudo reboot
```

```shell

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smartbit I think we can organize it better

# Generate SSH key to use when accessing machies
ssh-keygen -t rsa -b 4096 -N "" -C "root@example.com" -f ~/.ssh/rhce # empty password

# Make adding SSH key load to ssh agent automatic
eval $(ssh-agent); echo $'eval $(ssh-agent)' >> ~/.profile
ssh-add ~/.ssh/rhce; echo $'ssh-add ~/.ssh/rhce' >> ~/.profile

# Add Virtualbox GPG Key & repository
wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox_2016.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian `lsb_release -sc` non-free contrib" > /etc/apt/sources.list.d/virtualbox.org.list'

# TODO remove linestarve.com and use alternative method to get latest version of vagrant
# Add a repository to download vagrant
sudo bash -c 'echo deb http://vagrant-deb.linestarve.com/ any main > /etc/apt/sources.list.d/wolfgang42-vagrant.list'
sudo apt-key adv --keyserver pgp.mit.edu --recv-key AD319E0F7CFFA38B4D9F6E55CE3F3DE92099F7A4

# Update packages list
sudo apt update

# TODO remove virtualbox version-number and automatically install latest version; dkms needed when upgrading kernel
# Install packages
sudo apt -y --force-yes install virtualbox-5.1 git vagrant # virtualbox-ext-pack dkms

# Download (clone) lab environment from GitHub
cd ~
git clone https://github.com/AnwarYagoub/RHCSA-RHCE-Lab-Environment.git
cd ~/RHCSA-RHCE-Lab-Environment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more comment is (almost) always better. Please push to the branch update_readme

@AnwarYagoub AnwarYagoub Dec 2, 2016

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will pull the latest changes and add comments.

# Generate SSH key to use when accessing machines
ssh-keygen -t rsa -b 4096 -N "" -C "root@example.com" -f ~/.ssh/rhce # empty password

# Make loading SSH key to ssh agent automatic
eval $(ssh-agent); echo $'eval $(ssh-agent)' >> ~/.profile
ssh-add ~/.ssh/rhce; echo $'ssh-add ~/.ssh/rhce' >> ~/.profile

# Add Virtualbox GPG Key & repository
wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox_2016.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian `lsb_release -sc` non-free contrib" > /etc/apt/sources.list.d/virtualbox.org.list'
export ubuntu_codename=`lsb_release -sc`
# which of the following 2 is easiest to maintain, has most chance to fail gracefully when yum implementation changes or Vbox gets new numbering scheme
export virtualbox_version=`wget --quiet -O - http://download.virtualbox.org/virtualbox/debian/dists/$ubuntu_codename/contrib/binary-amd64/Packages | awk 'match($0, /(virtualbox-[0-9]\.[0-9])/, a) {b=a[1]} END {print b}'` # depends on sorting in Packages file
export virtualbox_version=`wget --quiet -O - http://download.virtualbox.org/virtualbox/debian/dists/$ubuntu_codename/contrib/binary-amd64/Packages | awk 'match($0, /(virtualbox-[0-9]\.[0-9])/, a) {if (RSTART) { ++i; v[i]=a[1]}} END {n = asort (v); print v[n]}'`

# Get latest vagrant version
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | sed -nr '/.*href="\/vagrant\/([^/]*).*/{s//\1/p;q}' ` # from top of page
export vagrant_version=`wget --quiet -O - https://releases.hashicorp.com/vagrant/ | awk 'match($0, /href="\/vagrant\/([^/]*)/, a) {if (RSTART) { ++i; v[i]=a[1]}} END {n = asort (v); print v[n]}'`
wget https://releases.hashicorp.com/vagrant/"$vagrant_version"/vagrant_"$vagrant_version"_x86_64.deb -O vagrant_"$vagrant_version"_x86_64.deb

# Update packages list
sudo apt update

# Install packages
sudo apt -y install $virtualbox_version git ./vagrant_"$vagrant_version"_x86_64.deb; rm ./vagrant_"$vagrant_version"_x86_64.deb
```
55 changes: 55 additions & 0 deletions windows-vbx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

Tested on Windows 8.1 & Windows 10

# Prerequisites:
1. [VirtualBox][virtualBox] Visualization Software.
2. [Vagrant][vagrant] Software for building and maintaining portable virtual development environments.
3. Optional [PuTTY][PuTTY] SSH client since Windows does't natively have one.


There are two Installation methods available for MS.Windows:

- [Regular "Download and Install".](#regular-download-and-install)
- [Using a package manager for Windows like Chocolatey.](#windows-package-manager)


## Regular "download and install":
This method is well-known to Windows users, all you need to do is download
[VirtualBox][virtualBox-download], [Vagrant][vagrant-download] and optionally
[PuTTY][PuTTY-download].

Next, Install in the same **order**, VirtualBox then Vagrant.
***Note1: You need to have Visualization/Hyper-V Supported and Enabled***


***Note2: In Case you need to update both Vagrant and VirtualBox You need
to _REMOVE_ both then re-installing them in same order above to prevent
errors and failures my occur during update***


## Windows Package Manager:
This method may be new to some Windows users but its much more easier to install
and maintain since it blows away the D&I old method and make ease updating
packages for Windows. One good Windows package manager is [Chocolaty][Chocolaty].

You can find installation Guide in [Chocolaty official website][Chocolaty-install].
After Installing Chocolaty Install VirtualBox, Vagrant and optionally PuTTY
using the following commands with __administrator Privileges__:

```powershell
choco install virtualbox

choco install vagrant

choco install putty
```


[virtualBox]: https://www.virtualbox.org/
[virtualBox-download]: https://www.virtualbox.org/wiki/Downloads
[vagrant]: https://www.vagrantup.com/
[vagrant-download]: https://www.vagrantup.com/downloads.html
[PuTTY]: http://www.chiark.greenend.org.uk/~sgtatham/putty/
[PuTTY-download]: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
[Chocolaty]: http://chocolatey.org/
[Chocolaty-install]: https://chocolatey.org/install