Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
88 changes: 22 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,87 +14,43 @@ 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:**
```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
```
### 2. Install vagrant :

**2.1 Install vagrant on Debian-based Linux Ubuntu/Mint (64-bit):**
```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
```

**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 Vagranfile 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
74 changes: 74 additions & 0 deletions fedora-vbx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
### Install Vagrant using VirtualBox on Fedora 24

Tested for Fedora 24

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

# Get vagrant version
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]}'`

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
why two exports with the same variable name virtualbox_version ?
the last one will override the first.

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.

I was studying regex, sed & awk and came up with several alternatives. The other.md files have similar pairs and in c6bcfb3 you'll find even more alternatives.

What do you think, should we depend on the output order of yum & html pages, or should awk do the sorting? Any other suggestions, enhancements, questions, etc?

Ubuntu.md currently has three steps for installing vagrant:

  1. download the .deb file
  2. install it apt install ./vagrant_"$vagrant_version"_x86_64.deb
  3. delete it rm ./vagrant_"$vagrant_version"_x86_64.deb

whereas in CentOS/Fedora it is a simple yum install https://...._x86_64.rpm. Do you know how to put the .deb-url on the apt install command-line directly?

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.

What do you think, should we depend on the output order of yum & html pages, or should awk do the sorting? Any other suggestions, enhancements, questions, etc?

I mean when a user sees theses two command he/she may apply both of them. so why to put two of them if one can handle it properly

Ubuntu.md currently has three steps for installing vagrant:

download the .deb file
install it apt install ./vagrant_"$vagrant_version"x86_64.deb
delete it rm ./vagrant
"$vagrant_version"_x86_64.deb

whereas in CentOS/Fedora it is a simple yum install https://...._x86_64.rpm. Do you know how to put the .deb-url on the apt install command-line directly?

If we want to install .deb we should use dpkg with -i option or any other alternative apt-get used to install packages from repositories unlike yum which can handle install a local package.

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.

so why to put two of them if one can handle it properly

Because I didn't come to a conclusion which of the two (three) is better. What are your thoughts? After we made up our mind, we remove the other and have a reference left in the repository.

we should use dpkg with -i

Like this? It would put vagrant install on a single line, but then we'd have 2 lines for installing: dpkg for vagrant & apt install for git & virtualbox.
That would give 2 options 1) apt install & dpkg -i 2) download, apt install, rm. Which do you prefer?


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

# 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
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]}'`

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

# Check vagrant version
vagrant --version

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

If Fedora runs without GUI, then execute these 2 commands:
```shell
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'
```
31 changes: 31 additions & 0 deletions rhel-centos7-kvm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### Install Vagrant using KVM on RHEL/CentOS 64-bit


```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
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]}'`
# 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

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

If RHEL/CentOS runs without GUI, then execute these 2 commands:
```shell
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'
```
53 changes: 53 additions & 0 deletions rhel-centos7-vbx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
### Install Vagrant using VirtualBox on RHEL/CentOS 64-bit
```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
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
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]}'`

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

# Check vagrant version
vagrant --version

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

If RHEL/CentOS runs without GUI, then execute these 2 commands:
```shell
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'
```
51 changes: 51 additions & 0 deletions ubuntu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
### Ubuntu 16.04
Instructions for installing VirtualBox & Vagrant 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`
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

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

If ubuntu runs without GUI, then execute these 2 commands:
```shell
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'
```