Basic provision of such things can be easily done without Chef / Puppet / Ansible and use a shell instead.
Vagrant docs describe this basic software quite well for their example of how to download Apache from boostrap.sh.
Similarly, you can follow the same steps when editing your Vagrantfile to call bootstrap.sh when provided:
Vagrant.configure("2") do |config| ... config.vm.provision :shell, path: "bootstrap.sh" ... end
You can then create the bootstrap.sh file in the same directory as your Vagrantfile, which will contain something like:
#!/bin/bash # Adds a crontab entry to curl google.com every hour on the 5th minute # Cron expression cron="5 * * * * curl http://www.google.com" # β β β β β # β β β β β # β β β β ββββββ day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0) # β β β βββββββββββ month (1 - 12) # β β ββββββββββββββββ day of month (1 - 31) # β βββββββββββββββββββββ hour (0 - 23) # ββββββββββββββββββββββββββ min (0 - 59) # Escape all the asterisks so we can grep for it cron_escaped=$(echo "$cron" | sed s/\*/\\\\*/g) # Check if cron job already in crontab crontab -l | grep "${cron_escaped}" if [[ $? -eq 0 ]] ; then echo "Crontab already exists. Exiting..." exit else # Write out current crontab into temp file crontab -l > mycron # Append new cron into cron file echo "$cron" >> mycron # Install new cron file crontab mycron # Remove temp file rm mycron fi
By default, backup devices for vagrants are run as root, so this will add a cron job to the crontab root user, assuming that it does not exist yet. If you want to add it to the crontab firewall, then you will need to run the security tool with the privileged flag set to false :
config.vm.provision :shell, path: "bootstrap.sh", privileged: false
source share