Skip to content

Latest commit

 

History

History

kali

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Kali Vagrantfile


Description

This Vagrantfile is based on the Official kalilinux/rolling box. It performs the actions listed below, in that order, as the user specified (The "root or vagrant" steps depend on the $run_as_root variable). Refer to Variables for more info on the $variables.

  1. Create VM with the name $vm_name in VirtualBox.
  2. Pull down the kalilinux/rolling Vagrant box.
  3. Set hostname to $hostname.
  4. Sync $local_shared_dir on the host to /vagrant in the guest Kali VM.
  5. Disable the "VirtualBox Remote Desktop" server which Kali(???) is enabling???
  6. (root) Check for updated packages, upgrade system packages, and install the specified $apt_packages as well as the Python apt dependencies for required and optional modules.
  7. (root) Change the login shell to $preferred_shell for (root or vagrant) depending on $run_as_root.
  8. (root or vagrant) If ~/.pyenv does not exist, install pyenv via the hated pipe to bash method. Add the pyenv setup config to /etc/profile.d/pyenvrc, and source that file from ~/.profile and the $preferred_shell home rc file.
  9. (root or vagrant) Install $python_version using pyenv and set it as the pyenv global version. Install the specified $pip_packages into that pyenv, and upgrade its pip and pipx
  10. (root or vagrant) If a list of $git_repos is specified, clone them to $git_repos_dir. See Variable footnote #3 for some implementation details.
  11. (root or vagrant) If a list of $pipx_projects is specified, run pipx install to install them into the pyenv global $python_version environment and then run pipx ensurepath to make sure they are accessible upon login.
  12. (root or vagrant) Run the user specified $custom_setup_script and copy that script to /vagrant/vagrant-custom-setup.sh.

Variables

This chart is the list of variables in the top of the Vagrantfile which you are encouraged to update based on your needs. To keep it DRY, rather than document default values here, please just see the corresponding Vagrantfile.

Variable Type Description
vm_name String Used as VM name
hostname String Used as VM hostname
preferred_shell String Name, not path1. Used to change the login shell for the (root or vagrant) user (based on $run_as_root, in order to update $HOME/.*rc files appropriately for pyenv and pipx
local_shared_dir String The directory on the system which will be mounted to /vagrant in the VM
run_as_root boolean Whether or not to run the shell provisioners as root2. If false, uses the vagrant user
python_version String Any pyenv supported version of Python, including the unlisted major or major.minor versions, like 3 or 3.12. This will be set as the pyenv global default
apt_packages Array[String] The packages you need/want installed in the VM. You do NOT need to handle the Python dependencies here, just yours
git_repos_dir String The full path to the directory you want to clone github repos in to3
git_repos Array[String] The https URLs to the git repos the user wants to clone WITHOUT THE .git at the end (the basename will be used to determine if it is already cloned)
pip_packages Array[String] The pip packages to install into the pyenv global default (pipx will be installed here already)
pipx_packages Array[String] A list of directories (full path) which contain Python projects on which pipx install will be executed to install them into the pyenv global default
custom_setup_script Heredoc (Squiggly Unquoted)4 This is where your custom setup script goes. Example: adding a cd /vagrant to the $preferred_shell rc file to always start in the shared directory

Footnotes:

  • 1 - Example: bash. Only tested with bash and zsh.
  • 2 - The apt install and chsh provisioners will be run as root regardless of this setting.
  • 3 - If $run_as_root is false and the non-root user doesn't have write perms in the specified $git_repos_dir, sudo will be used with the git clone operation seeing as the Vagrantfile can run sudo anyways. As an example, /opt is a traditional directory to throw optional additional software, and the default for this Vagrantfile, but the vagrant user cannot write there without sudo. The cloned directories (NOT $git_repos_dir itself), will have their ownership changed to the non-root user in this situation.
  • 4 Aka Interpolation and Esacaping is enabled, indentation is allowed but will be cleaned up on the final script.

Changelog

  • 1.0 - Initial Release