The file config.sh.template contains default values. A copy (ignored by git) should be created, that is called config.sh.
To run the config file, invoke vagrant.sh instead of vagrant. Pass the same arguments you'd pass to vagrant, for example:
./vagrant.sh destroy --force
There's also a shortcut. If you call vagrant.sh UP (uppercase, no arguments) you'll run:
./vagrant.sh destroy --force./vagrant.sh up
Under the hood
The configuration file will export some environment variables, making them accessible for the Vagrantfile as ENV[var_name]. Some of them will be used by the Vagrantfile itself. Others will be passed to install.sh as $var_name.
The Vagrantfile should always set a default (ENV[var] || val) rather than assuming that the variable is set.
Examples
I made two examples:
BOX (default: "generic/ubuntu2204") is the image name. It's used directly by the Vagrantfile. If you change it, running vagrant destroy directly will fail, so it's better to always use vagrant.sh.
OS_SWAPPINESS (default: 1) sets the Linux swappiness. Let's try to use the prefixes consistently.
After you test & approve this change, you could refactor S3 options so that they are defined in the new way.
User level changes
The file
config.sh.template
contains default values. A copy (ignored by git) should be created, that is calledconfig.sh
.To run the config file, invoke
vagrant.sh
instead ofvagrant
. Pass the same arguments you'd pass to vagrant, for example:./vagrant.sh destroy --force
There's also a shortcut. If you call
vagrant.sh UP
(uppercase, no arguments) you'll run:./vagrant.sh destroy --force
./vagrant.sh up
Under the hood
The configuration file will export some environment variables, making them accessible for the Vagrantfile as
ENV[var_name]
. Some of them will be used by the Vagrantfile itself. Others will be passed toinstall.sh
as$var_name
.The Vagrantfile should always set a default (
ENV[var] || val
) rather than assuming that the variable is set.Examples
I made two examples:
BOX
(default: "generic/ubuntu2204") is the image name. It's used directly by the Vagrantfile. If you change it, runningvagrant destroy
directly will fail, so it's better to always usevagrant.sh
.OS_SWAPPINESS
(default: 1) sets the Linux swappiness. Let's try to use the prefixes consistently.After you test & approve this change, you could refactor S3 options so that they are defined in the new way.