diff --git a/README.md b/README.md index 40593c2..7cf9f80 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,19 @@ # RHCE 8 Automated Practice Deployment -_Powered by Ansible and Vagrant_ +_Powered by Ansible and Vagrant_ ## Installation options below: ## macOS _Gatekeeper will block virtualbox from installing. All you have to do is go into Security & Privacy of System Preferences and click Allow under the General tab and rerun installation._ ##### Install all at once with the command below: -``` -/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" && xcode-select --install &&brew install ansible ; brew install python ; brew cask install vagrant ; brew cask install VirtualBox ; brew cask install virtualbox-extension-pack ; vagrant plugin install vagrant-guest_ansible +```shell +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" && \ + xcode-select --install && \ + brew install ansible ; \ + brew install python ; \ + brew cask install vagrant ; \ + brew cask install VirtualBox ; \ + brew cask install virtualbox-extension-pack ; \ + vagrant plugin install vagrant-guest_ansible ``` ##### Alternatively, you can install everything individually below. @@ -26,12 +33,38 @@ _NOTE - If it's been awhile since you've run yum update, do that first. Reboot i _NOTE2 - If you receive an error for an ansible guest vagrant plugin, DO NOT worry, as there are two different plugins related to Ansible and only one needs to be installed._ ##### For CentoOS/RHEL7/Manjaro/Arch (Continue below for RHEL 8 specific script) -``` -systemctl stop packagekit; yum install -y epel-release && yum install -y git binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms libvirt libvirt-devel ruby-devel libxslt-devel libxml2-devel libguestfs-tools-c ; mkdir ~/Vagrant ; cd ~/Vagrant ; curl -o vagrant_2.2.6_x86_64.rpm https://releases.hashicorp.com/vagrant/2.2.6/vagrant_2.2.6_x86_64.rpm && yum install -y vagrant_2.2.6_x86_64.rpm && vagrant plugin install vagrant-guest_ansible ; vagrant plugin install vagrant-guest-ansible ; wget -O /etc/yum.repos.d/virtualbox.repo wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo ; yum install -y VirtualBox-6.0 && systemctl start packagekit +```shell +VAGRANT_VERS="2.2.19" && \ + systemctl stop packagekit; \ + yum install -y epel-release && \ + yum install -y git binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms libvirt libvirt-devel ruby-devel libxslt-devel libxml2-devel libguestfs-tools-c ; \ + mkdir ~/Vagrant ; \ + cd ~/Vagrant ; \ + curl -o vagrant_${VAGRANT_VERS}_x86_64.rpm https://releases.hashicorp.com/vagrant/${VAGRANT_VERS}/vagrant_${VAGRANT_VERS}_x86_64.rpm && \ + yum install -y vagrant_${VAGRANT_VERS}_x86_64.rpm && \ + vagrant plugin install vagrant-guest_ansible ; \ + vagrant plugin install vagrant-guest-ansible ; \ + wget -O /etc/yum.repos.d/virtualbox.repo http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo ; \ + yum install -y VirtualBox-6.1 && \ + echo "* 0.0.0.0/0" >> "/etc/vbox/networks.conf" && \ + systemctl start packagekit ``` ##### If you're using RHEL 8, use the script below: -``` -systemctl stop packagekit; dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm ; dnf install -y git binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms libvirt libvirt-devel ruby-devel libxslt-devel libxml2-devel libguestfs-tools-c ; mkdir ~/Vagrant ; cd ~/Vagrant ; curl -o vagrant_2.2.19_x86_64.rpm https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_x86_64.rpm && dnf install -y vagrant_2.2.19_x86_64.rpm && vagrant plugin install vagrant-guest_ansible ; wget -O /etc/yum.repos.d/virtualbox.repo wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo ; dnf install -y VirtualBox-6.1 && /usr/lib/virtualbox/vboxdrv.sh setup ; usermod -a -G vboxusers root ; systemctl start packagekit +```shell +VAGRANT_VERS="2.2.19" && \ + systemctl stop packagekit; \ + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm ; \ + dnf install -y git binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms libvirt libvirt-devel ruby-devel libxslt-devel libxml2-devel libguestfs-tools-c ; \ + mkdir ~/Vagrant ; cd ~/Vagrant ; \ + curl -o vagrant_${VAGRANT_VERS}_x86_64.rpm https://releases.hashicorp.com/vagrant/${VAGRANT_VERS}/vagrant_${VAGRANT_VERS}_x86_64.rpm && \ + dnf install -y vagrant_${VAGRANT_VERS}_x86_64.rpm && \ + vagrant plugin install vagrant-guest_ansible ; \ + wget -O /etc/yum.repos.d/virtualbox.repo http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo ; \ + dnf install -y VirtualBox-6.1 && \ + /usr/lib/virtualbox/vboxdrv.sh setup ; \ + usermod -a -G vboxusers root ; \ + echo "* 0.0.0.0/0" >> "/etc/vbox/networks.conf" && \ + systemctl start packagekit ``` ##### Also, install the Virtualbox extension pack below - [Install the Virtual Box Extension Pack](https://www.virtualbox.org/wiki/Downloads) @@ -43,13 +76,24 @@ systemctl stop packagekit; dnf -y install https://dl.fedoraproject.org/pub/epel/ 4. Run `vagrant up` to deploy the environment (If the environment has a designated repo VM it will take the longest to deploy the first time only, this is because the repo system has all the packages available to the base release but will be quicker on subsequent deployments.) ## Windows/Fedora -- If using Windows: +### If using Windows: - [Install the Latest Version of Vagrant](https://www.vagrantup.com/downloads.html) - [Install the Latest Version of Virtualbox and Virtual Box Extension Pack](https://www.virtualbox.org/wiki/Downloads) -- Then install the following vagrant plugin via PowerShell as Administrator `vagrant plugin install vagrant-guest_ansible` -- If using Fedora, run `dnf update -y` to update your system, then run the script below as root to install everything at once: -``` -dnf -y install wget git binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms libvirt libvirt-devel ruby-devel libxslt-devel libxml2-devel ; wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo ; mv virtualbox.repo /etc/yum.repos.d/virtualbox.repo ; dnf install -y VirtualBox-6.0 ; usermod -a -G vboxusers ${USER} ; /usr/lib/virtualbox/vboxdrv.sh setup ; dnf -y install vagrant ; dnf remove -y rubygem-fog-core ; vagrant plugin install vagrant-guest_ansible +- Then install the following vagrant plugin via PowerShell as Administrator `vagrant plugin install vagrant-guest_ansible` + +### If using Fedora, +- run `dnf update -y` to update your system, then run the script below as root to install everything at once: +```shell +dnf -y install wget git binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms libvirt libvirt-devel ruby-devel libxslt-devel libxml2-devel ; \ + wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo ; \ + mv virtualbox.repo /etc/yum.repos.d/virtualbox.repo ; \ + dnf install -y VirtualBox-6.1 ; \ + usermod -a -G vboxusers ${USER} ; \ + /usr/lib/virtualbox/vboxdrv.sh setup ; \ + dnf -y install vagrant ; \ + dnf remove -y rubygem-fog-core ; \ + echo "* 0.0.0.0/0" >> "/etc/vbox/networks.conf" && \ + vagrant plugin install vagrant-guest_ansible ``` ##### Once the above software is installed. Do the following if you're running the environment on Windows: @@ -63,8 +107,19 @@ dnf -y install wget git binutils gcc make patch libgomp glibc-headers glibc-deve _NOTE - If it's been awhile since you've run apt update, do that first. Reboot if the kernel was updated._ ##### Install all at once by Copy/Pasting the below command into your terminal as root. -``` -sudo snap install ruby ; sudo apt install ruby-bundler git -y; wget -c https://releases.hashicorp.com/vagrant/2.2.6/vagrant_2.2.6_x86_64.deb ; sudo dpkg -i vagrant_2.2.6_x86_64.deb ; wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - ; wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - ; sudo add-apt-repository "deb http://download.virtualbox.org/virtualbox/debian bionic contrib"; sudo apt update; sudo apt install -y virtualbox-6.0 ; vagrant plugin install vagrant-guest_ansible +```shell +VAGRANT_VERS="2.2.19" && \ + sudo snap install ruby ; \ + sudo apt install ruby-bundler git -y; \ + wget -c https://releases.hashicorp.com/vagrant/${VAGRANT_VERS}/vagrant_${VAGRANT_VERS}_x86_64.deb ; \ + sudo dpkg -i vagrant_${VAGRANT_VERS}_x86_64.deb ; \ + wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - ; \ + wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - ; \ + sudo add-apt-repository "deb http://download.virtualbox.org/virtualbox/debian bionic contrib"; \ + sudo apt update; \ + sudo apt install -y virtualbox-6.0 ; \ + echo "* 0.0.0.0/0" >> "/etc/vbox/networks.conf" && \ + vagrant plugin install vagrant-guest_ansible ``` ##### Also, install the Virtualbox extension pack below - [Virtual Box Extension Pack](https://www.virtualbox.org/wiki/Downloads) @@ -87,7 +142,7 @@ _NOTE this requires a free Github account_ 4. You are also able to easily pull changes when they're made available. ## Notable Vagrant Commands to control the environment: -- `ansible-playbook playbooks/reset.yml` - Used for resetting the environment after attempting the practice exam in the Red Hat Certs Slack workspace practice exam channel. +- `ansible-playbook playbooks/reset.yml` - Used for resetting the environment after attempting the practice exam in the Red Hat Certs Slack workspace practice exam channel. - `vagrant up` - Boots and provisions the environment - `vagrant destroy -f` - Shuts down and destroys the environment - `vagrant halt` - Only shuts down the environment VMs (can be booted up with `vagrant up`) @@ -147,3 +202,6 @@ Error is usually "VT-x is not available. (VERR_VMX_NO_VMX)" or similar, when the Resolution seems to be either remove HyperV, or preventing its hypervisor from starting with the command: bcdedit /set hypervisorlaunchtype off, followed by a reboot. + +On AMD processors, the VMs can hung during reboots with the error: +`watchdog : BUG : soft lockup - CPU stuck for 22-23 secs` diff --git a/Vagrantfile b/Vagrantfile index c996dbb..328dc9d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,21 +13,21 @@ config.vm.box_check_update = false # Repo config.vm.define "repo" do |repo| - repo.vm.box = "rdbreak/rhel8repo" + repo.vm.box = "rdbreak/rhel8repo" repo.vm.provider "virtualbox" do |repo| repo.memory = "1024" unless File.exist?(file_to_disk5) repo.customize ['createhd', '--filename', file_to_disk5, '--variant', 'Standard', '--size', 2 * 1024] repo.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 1] - repo.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk5] - end + repo.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk5] + end end - repo.vm.provision :shell, :inline => "pvs | grep '/dev/sdb' && echo 'The disk was already expanded!' || (pvcreate /dev/sdb; vgextend rhel_rhel8 /dev/sdb; lvextend -l +100%FREE /dev/rhel_rhel8/root; xfs_growfs /dev/rhel_rhel8/root)" + repo.vm.provision :shell, :inline => "pvs | grep '/dev/sdb' && echo 'The disk was already expanded!' || (pvcreate /dev/sdb; vgextend rhel_rhel8 /dev/sdb; lvextend -l +100%FREE /dev/rhel_rhel8/root; xfs_growfs /dev/rhel_rhel8/root ; dracut --regenerate-all --force)" repo.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd;", run: "always" repo.vm.provision :shell, :inline => "yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y; sudo yum install -y sshpass python3-pip python3-devel httpd sshpass vsftpd createrepo", run: "always" repo.vm.provision :shell, :inline => " python3 -m pip install -U pip ; python3 -m pip install pexpect; python3 -m pip install ansible", run: "always" - repo.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/" + repo.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "*.vdi"] repo.vm.network "private_network", ip: "192.168.55.199" end @@ -46,7 +46,7 @@ config.vm.define "node1" do |node1| node1.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk1] end end - + node1.vm.provision "shell", inline: <<-SHELL yes| sudo mkfs.ext4 /dev/sdb SHELL @@ -68,7 +68,7 @@ config.vm.define "node2" do |node2| node2.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk2] end end - + node2.vm.provision "shell", inline: <<-SHELL yes| sudo mkfs.ext4 /dev/sdb SHELL @@ -90,7 +90,7 @@ config.vm.define "node3" do |node3| node3.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk3] end end - + node3.vm.provision "shell", inline: <<-SHELL yes| sudo mkfs.ext4 /dev/sdb SHELL @@ -112,7 +112,7 @@ config.vm.define "node4" do |node4| node4.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk4] end end - + node4.vm.provision "shell", inline: <<-SHELL yes| sudo mkfs.ext4 /dev/sdb SHELL