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
.
- Create VM with the name
$vm_name
in VirtualBox. - Pull down the kalilinux/rolling Vagrant box.
- Set hostname to
$hostname
. - Sync
$local_shared_dir
on the host to/vagrant
in the guest Kali VM. - Disable the "VirtualBox Remote Desktop" server which Kali(???) is enabling???
- (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. - (root) Change the login shell to
$preferred_shell
for (root or vagrant) depending on$run_as_root
. - (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. - (root or vagrant) Install
$python_version
usingpyenv
and set it as thepyenv global
version. Install the specified$pip_packages
into thatpyenv
, and upgrade its pip and pipx - (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. - (root or vagrant) If a list of
$pipx_projects
is specified, runpipx install
to install them into thepyenv global
$python_version
environment and then runpipx ensurepath
to make sure they are accessible upon login. - (root or vagrant) Run the user specified
$custom_setup_script
and copy that script to/vagrant/vagrant-custom-setup.sh
.
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 withbash
andzsh
. - 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 thegit 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 thevagrant
user cannot write there withoutsudo
. 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.
- 1.0 - Initial Release