lavabit / robox

The tools needed to robotically create/configure/provision a large number of operating systems, for a variety of hypervisors, using packer.
620 stars 139 forks source link

How can I reconfigure and reduce the rhel8 box use smaller root/disk size and push it to vagrant cloud #237

Closed hethkar closed 2 years ago

hethkar commented 2 years ago

I would like to reconfigure generic/rhel8 with smaller root disk (ex: 16 GiB instead of what is available) for virtualbox and build my own box on vagrant cloud ? How can I achieve this for the mentioned scenario.

ladar commented 2 years ago
git clone https://github.com/lavabit/robox/ && cd robox
sed -i 's/131072/16384/g' generic-virtualbox.json
./robox.sh box generic-rhel8-virtualbox

Assuming you have Packer and VirtualBox setup already, that should generate new box files for you. If you don't, look at the res/providers/providers.sh script fro a guide - just be aware that script was written specifically for CentOS 7 hosts, and way not work as-is on other systems.

Also, the RHEL ISO is being pulled from Archive.org and there servers are rather slow. Given the file size, you may want to update the URL, or add the file to your packer cache by to avoid the 4-8 hour download.

hethkar commented 2 years ago

@ladar Thank you for the guidance.
I have got some questions

  1. Updating the URL at ./packer-cache.json: "iso_url": "https://archive.org/download/rhel-8.5/rhel-8.5-x86_64-dvd.iso", to a local file location(/Users/user1/Downloads/rhel-8.5-x86_64-dvd.iso) would be enough or same should be updated in ./generic-virtualbox.json: "iso_url": "https://archive.org/download/rhel-8.5/rhel-8.5-x86_64-dvd.iso", ?

Update: I tried updating both locations with localpath for rhel-8.5-x86_64-dvd.iso and edited disk size and ran the mentioned command and got the below boxes successfully.

generic-rhel8-virtualbox-3.6.14.box
generic-rhel8-virtualbox-3.6.14.box.sha256
roboxes-rhel8-virtualbox-3.6.14.box     
roboxes-rhel8-virtualbox-3.6.14.box.sha256
  1. What's the difference between generic and roboxes- ?

  2. I assume there is a script for uploading the box to the vagrant cloud, I am failing to achieve it.

    
    ./res/scripts/direct.sh output/generic-rhel8-virtualbox-3.6.14.box

parse error: Invalid numeric literal at line 1, column 10 parse error: Invalid numeric literal at line 1, column 10

generic-rhel8-virtualbox-3.6.14.box failed to upload..

Note: I updated .credentialsrc with my vagrant token.


Intention is to use same version numbers as upstream, except it will be pointing to my vagrant account with edited description and want upload the box.Can you please point the script(I guess it's in res/scripts) and its usage to achieve this ? 

4.  Is it possible to customise and  make use of `rhel-8.0-x86_64-boot.iso` (780MB) instead of the  rhel-8.5-x86_64-dvd.iso (which is 10 GB)  ? What changes should I make to achieve this ? 
ladar commented 2 years ago

@ladar Thank you for the guidance. I have got some questions

  1. Updating the URL at ./packer-cache.json: "iso_url": "https://archive.org/download/rhel-8.5/rhel-8.5-x86_64-dvd.iso", to a local file location(/Users/user1/Downloads/rhel-8.5-x86_64-dvd.iso) would be enough or same should be updated in ./generic-virtualbox.json: "iso_url": "https://archive.org/download/rhel-8.5/rhel-8.5-x86_64-dvd.iso", ?

The packer-cache.json is a "dummy" config that I use to pre-cache ISOs and other resources so it doesn't slow down the build pipeline... for it to work, you either need VMWare setup, or you need to fake it by creating a couple of empty files, orpacker` will bail out early.

If your only building a single box, there is no advantage to using it.

Update: I tried updating both locations with localpath for rhel-8.5-x86_64-dvd.iso and edited disk size and ran the mentioned command and got the below boxes successfully.

generic-rhel8-virtualbox-3.6.14.box
generic-rhel8-virtualbox-3.6.14.box.sha256
roboxes-rhel8-virtualbox-3.6.14.box       
roboxes-rhel8-virtualbox-3.6.14.box.sha256
2. What's the difference between `generic` and `roboxes-`  ?

They are the same, only the description/metadata is a little different to help with searching .

I settled on roboxes or "Robot Boxes" later, and started releasing the boxes under both names after. On Docker Hub/Quay, where generic isn't available, it's just roboxes.

3. I assume there is a script for uploading the box to the vagrant cloud, I am failing to achieve it.
./res/scripts/direct.sh output/generic-rhel8-virtualbox-3.6.14.box

parse error: Invalid numeric literal at line 1, column 10
parse error: Invalid numeric literal at line 1, column 10

generic-rhel8-virtualbox-3.6.14.box failed to upload.. 

Note: I updated .credentialsrc with my vagrant token. 

The direct.sh and it's ancestor (non-direct version) silent.sh both use the filename to figure out where to upload the box, so they only work for us. You should try the res/scripts/uploader.sh script which lets you specify all those values manually.

If I had to guess about the error, it's possible the server is returning an error, and that's what it can't parse, since it's an HTTP error, and not JSON. Either that, or you don't have jq installed (not sure if I added the logic to check for jq yet).

Intention is to use same version numbers as upstream, except it will be pointing to my vagrant account with edited description and want upload the box.Can you please point the script(I guess it's in res/scripts) and its usage to achieve this ?

The current version is set at the top of robox.sh script. You can override it via the .credentialsrc file, or via the command line, but if you remove those, it should use the default. I also try to tag a commit with the version when I kickoff a new build, but that isn't always accurate.

Note, there is often a lag between when the version gets bumped and I upload. For example with 3.6.14, I never got around to QC'ing the boxes, and made so many changes to the scripts while working on Magma, that I decided to wipe out the files and restart last week. I checked on it yesterday, fixed the issues with 3 of the box configs, and started the upload a couple of hours ago.

Because of the way searching works, I wait until all of the boxes are available before uploading/releasing.

4. Is it possible to customise and  make use of `rhel-8.0-x86_64-boot.iso` (780MB) instead of the  rhel-8.5-x86_64-dvd.iso (which is 10 GB)  ? What changes should I make to achieve this ?

Sadly, no. Doing it that way would require embedding subscription info in the repo, so the box could use DNF.

At some point I'd like to update the RHEL configs so if they're being built in our environment, they can install updates using an internal repo, but haven't gotten around to it yet.

hethkar commented 2 years ago

@ladar Thank you for the response. Could you please tell how the name of the VM name is determined(in virtualbox) which is spun up from the .box file( generic-rhel8-virtualbox-3.6.14.box ) generated via ./robox.sh box generic-rhel8-virtualbox command.
How can I configure this ?

ladar commented 2 years ago

@hethkar are you referring to the name while being built by packer? That would be generic-rhel8-virtualbox. If you referring to the name once the box is created using vagrant? If undefined, a random name will get used, like generic-rhel8-virtualbox_1651531101218_22603 or workspace_default_1651508256907_71991 depending on how you have Vagrantfile setup.