Milestone #5: Fog - wAlber47/Tech-Journal GitHub Wiki
Configuring Machine for Fog
There are some basic things that need to be done prior to installing Fog on the machine. This includes:
- Creating an "fog" administrator account
- Setting the hostname to "fog"
- Static IP of
10.0.17.5
- Adding DNS Records for IP Address
- Configuring the Second Disk
Creating Fog Account
Fairly simple and should be able to do without a guide of sorts, however here are the steps:
sudo adduser fog
sudo passwd fog
, then enter in new credentials.sudo usermod -aG wheel fog
Setting Hostname
Use nmtui
to set the hostname to "fog".
Static IP Addressing
Use nmtui
to configure as follows:
- IPv4 Configuration: Manual
- Addresses: 10.0.17.5/24
- Gateway: 10.0.17.2
- DNS Servers: 10.0.17.4
- Search Domains: alber.local
Adding DNS Records
Fairly simple and should be able to do without a guide of sorts, however here are the steps:
- Open DNS Manager on
server19
. - Navigate to the Forward Lookup Zones for
alber.local
. - Right click and select New Host (A or AAAA), then add in the information.
- Make sure creating the associated PTR record is also selected. After that you can finish and close the DNS Manager.
Second Disk Configuration
Make sure that the machine has two disks, can check this using fdisk -l
. We will use /dev/sdb
to store our virtual machines that will be deployed from Fog.
- Become root using
sudo -i
. - Run
fdisk /dev/sdb
to begin configuring out disk. - We will use fdisk to create a second partition within the disk. We will enter n for new partition, then p, then simply follow the defaults that are set.
- Now we write the partition, do this by typing w. By running
fdisk -l
again we can see there is an empty partition. This is done withmkfs.ext4 /dev/sdb1
, may take a moment. - Lastly, we need to mount this to a directory as that is how Linux handles this. We muse modify a file called
/etc/fstab
to reflect this:
- Use
mount -a
to check that everything is done properly. We should have alost+found
file within our/images
directory.
Installing Fog
We will use the source version of Fog directly from GitHub. Can be found here.
- Install
git
usingsudo yum install git
. - Then clone the Fog repository using
git clone https://github.com/FOGProject/fogproject.git
. - We should turn off SELinux as Fog does not get along with this service.
- Edit
/etc/selinux/config
, changeSELINUX=enforcing
toSELINUX=permissive
.
- Edit
- In addition to this, instead of turning off the firewall, we will create rules to allow the services we need.
- To start out, we can run the
fogproject/bin/installfog.sh
and make the configuration look as follows. The installation may take some time. Once you hit this screen, open a new root session on fog and follow the configuration.
Before navigating to the link seen in this image, we need to allow services through the firewall.
Setting Firewall Rules
We need to add ftp
, https
, mountd
, mysql
, nfs
, proxy-dhcp
, rpc-bind
, and tftp
through the firewall.
This can be done by running this command while swaping out the service name:
sudo firewall-cmd --zone=public --add-service=<service-name> --permanent
Once all the services are entered, run sudo firewall-cmd --reload
.
Permission Configuration
We also need to change the permissions using chmod -R 775 /images
& chown root:fogproject -R /images
so that they can be accessed by Fog.
Now that all of this is complete, we can proceed with the installation. Head to the web portal at 10.0.17.5
and follow those steps. Once you get to the login screen, head back to the terminal and proceed. This should have you set a username and password. Once the installation finishes, head back to the web portal and log in. Make sure all the graphs are green before proceeding.
Setting DHCP Options
On our domain controller, we need to configure DHCP options so that we can PXE boot onto machines. This can be done by going to Scope Options -> Configure Options..., and then setting them as follows:
Fog Capture and Deploy
Extracting Base Image
For this piece, we will be extracting the snapshots that we created when initially setting up our virtual machines, specifically for xubuntu-wan
.
- To start, open CMD and invoke powershell with
pwsh
. - Create a connection to our vCenter instance with
$vserver = "vcenter.alber.local"
andConnect-VIServer($vserver)
. - Initialize our
$vm
variable with$vm = Get-VM -Name xubuntu-wan
. - Next, we will carve out the snapshot with `$snapshot = Get-Snapshot -VM $vm -Name "Base".
- To use this, we are going to create another linked clone. But before we do that, we need to create some base variables to be used in the process:
$vhost = Get-VMHost -Name "super4.cyber.local"
$ds = Get-Datastore -Name "datastore2-super4"
linkedname = "{0}.linked" -f $vm.name
- To create the linked clone, run
$linkedvm = New-VM -LinkedClone -Name $linkedname -VM $vm -ReferenceSnapshot $snapshot -VMHost $vhost -Datastore $ds
. - Now that we've gotten the base in a linked clone, we want to separate this link to create a standalone VM. Use
$newvm = New-VM -name "uxubuntu-20.04-base" -VM $linkedvm -VMHost $vhost -Datastore $ds
, this should run and then create the new VM. - Then give the VM a snapshot with
$newvm | New-Snapshot -Name "Base"
, as it will come with none. - Finally, we remove the linked VM as that was just a temporary step to create the base virtual machine. Use
$linkedvm | Remove-VM
.
Setting Capture Target
The steps for creating the capture target we want, are almost exactly similar to here. When we created a linked clone for the Fog virtual machine, the only switch is the $base_vm
should point to the xubuntu-20.04-base
. Also, the name should be xubuntu-capture-target
.
Capturing Image
Before we start capturing the image and sending it to Fog, we want to prepare Fog for this process. To start, log into Fog at https://fog/fog
. Navigate to "Images", then "Create New Image". Configure the settings as follows, everything else can be left to default:
We can add it, then view all the images to see it was created.
Then, set the Virtual Machine to force boot during the next power on. We can now boot up the machine that we created and begin sending the image to Fog.
Once it boots to the Bios, navigate to Boot and change the Network to boot first. It should load into Fog now. We are going to do a Quick Registration. It's going to begin, and we are going to shut down the virtual machine.
If we navigate back to Fog, then hosts, then List All Hosts, we should now see a New Host that has been created for our xubuntu-20.04-base
machine. Select the capture task, and under the Operating System drop-down, click on the correct option.
Once that is complete, we can go to Tasks -> List All Hosts -> Capture, this should add an active task to the menu.
Now head back to vCenter, make sure the boot options are set, and then power on the Virtual Machine again. Once you boot from the Network, you should enter the image capture session, this will look very similar to this:
This will run for a while, then we should be able to see our virtual machine within Fog. Once this is done, we can remove the xubuntu-capture-target
virtual machine.
Deploying Image
Now that the image is uploaded to our Fog server, we can pull it down when we want to create new Virtual Machines.
In order to test this, we are going to create a new VM titled xubuntu-deploy
. Place this on Datastore2, set ESXi to 6.5, OS to Ubuntu Linux (64-bit), 2GB RAM, hard drive 31GB, place on 480-WAN, and make sure to thin provision the hard drive.
Just like we did with the capture, we want to force Bios setup and boot to the Network. You may get booted out quickly so when you get to the Fog menu, navigate to Deploy Image, then log in with fog credentials.
Our capture image should pop up, and that should be selected. Deploying this image may take some time and will look something like this after a minute or so:
Once the process finishes, we can select Boot from Hard Disk, and xubuntu
should boot up.
Another OS Creation
This piece of the Wiki will hold the screenshots and deliverables for going through the base vm creation, fog capture and deploy process.
The Operating System that I will be using is Windows 10.
✅ Created Windows 10 Base VM
✅ Sys-Prepped the Machine
✅ Captured by Fog
✅ Deployed Workstation VM (wks1) to Domain using Windows 10 Fog Capture
✅ Booted wks1 to Windows 10 Successfully