Can I - vagrant add box - inside a Vagrantfile? - vagrant

If I understood correctly, the intention with using vagrant is to have a workflow in which the developer pulls the project sources along with the Vagrantfile, runs "vagrant up" and that's it right? The developer is not suppose to list and add boxes right, he shouldn't care about devops... that's the intention, to create as little friction as possible before a developer will be up and running, and let him/her focus on the app they're building... so? can I include in the Vagrant file adding boxes? only if they are not available? hey - what about vagrant plugins? can I add those to the Vagrantfile too? Is Vagrant smart enough not to run unnecessary provisioning twice? cheers, Ajar

You can instruct in your Vagrant file which base box should be used as the starting point. If this box is not found on the host, Vagrant will try to download it from Atlas (Vagrant's box repository) or from custom link if provided. Read about config.vm.box and config.vm.box_url config options.
No, Vagrant plugins need to be installed manually from command line. You can add check in Vagrantfile to see if plugin is installed or not. See this answer for more info.
Vagrant will run provision only once when VM is created. You can re-run provision if needed from command line, but Vagrant doesn't know anything about what your provision is doing. It's just executing it. If you use solutions such as Puppet/Chef/Ansible to run provision, they are "smart enough" not to repeat the same provision steps if the desired state was achieved.

Related

Puphpet - Adding custom files to hiera.yaml

I asked for this question on the github repo but no one answered me :/ (see this topic)
Here is my original question :
I would like to customize the hiera.yaml, adding new conf files to the ":hierarchy:" section.
But it seems it doesn't work when I do a "vagrant up" :/
Do I have to destroy and re-up my vagrant box ?
The reason why I want to add custom files to hiera.yaml is that I have multiple boxes and I would like to define my vhosts, sql databases and users, etc... for all of them at once.
Anyone has a solution to my problem ?
Thanks !
If you already built the VM, provisioning is not run on following vagrant up (only the initial one will run the provisioning)
If you need to force a provisioning after you change the hiera.yaml file is to run
$ vagrant provision
or
$ vagrant up --provision

Existing GIT repo with vagrant file

I just started using Vagrant. Now, One of my clients shared a GIT repo with the following files & directories :
Vagrantfile (file)
Vagrant (directory)
Now, I don't understand what will be my next step ? Every resource in the internet assumes that I am creating a new box from scratch (vagrant init hashicorp/precise64). But, here I need to match the box environment that is shared with me.
Thanks.
As stated in the previous answers - download the repository, and enter (cd via command line) the directory.
Once in there - you should just be able to run vagrant up to initiate the download and configuration of the vagrant box. Your client will (in theory) have set up the Vagrantfile to configure the machine appropriately.
Note: It might be worth checking to see if they have specified a hostname for the box [i.e mynewproject.dev] (found in Vagrantfile or sometimes, in a .yaml configuration file (i.e site.yaml).
If they have - it would be worth updating your hosts file to make sure you can use the host name locally.
The Vagrantfile will described everything about the VM you will build, so it knows about the vagrant box to use, you will have something like
Vagrant.configure("2") do
....
config.box = "hashicorp/precise64"
...
end
If the box is available freely on Atlas (such as hashicorp/precise64) vagrant will download the box and spin a new VM. If the box is not freely available, you will need to install yourself with vagrant box add

Changing a manifest file on a puppet master, how to get it to take hold

I'm fairly new to Puppet and am using Puppet 3.x. Right now I have a puppet master running locally, which I connect to using vagrant ssh.
At the moment if I change a manifest file on that puppet master I'm logging out of ssh and calling vagrant destroy, followed by vagrant up.
This takes a good 10 minutes. Is there a faster/better way of doing this? I'm looking at librarian-puppet but am not sure whether / how to use it in this circumstance.
Re-Run Provisioners
If you've already provisioned the machine at least once, you can make changes to your manifests and then run:
vagrant provision
on the host. This will re-run any provisioners without requiring a new Vagrant instance to be built and provisioned for the first time. In most cases, unless you have a pathological set of manifests, this will be significantly faster.

Using dotcloud and vagrant together

Has anyone thought about using dotcloud and vagrant together? It would be super sweet to be able to type "vagrant up" into a dotcloud application and have vagrant read from the dotcloud.yml file and create an local environment that would mirror what it would look like if you did a "dotcloud push".
I have a semi-working version, but it isn't automatic. You just create both the dotcloud.yml and Vagrantfile in the same folder and have slightly different setup scripts.
I think the nearest thing you could use would be http://docker.io

downloaded vagrant box file but what to do with it

I had a dev setup the vagrant box and he uploaded the file which I now have on my local machine. But I am not sure how to use it as I never used vagrant before. Can someone help with the docs or directions.
thanks
Full documentation for Vagrant can be found on the website. From a practical point of view, a Vagrant box is just a provisioned VirtualBox VM.
If someone else gave you the box, they can show you how to log into it as well. After that, get coding!
Having the box file is one of the steps to have a proper development environment configured. You also need to have the configuration file vagrantfile.
Vagrant is meant to run with one Vagrantfile per project. For example; if your project path is located at C:\vagrant\project01\, inside that folder you need to put the vagrantfile related to that box. Remember this file should contain the configuration for the box that you previously downloaded.
In the case that you don’t have this file but want to use the box to adapt it to you needs you can also can configure Vagrant for that. You just need to go to the cmd, and cd (got to directory) folder of the project, in this case C:\vagrant\project01\. In the cmd windows type vagrant init and Vagrant will generate a vagrantfile for this project. In that file you can modify the config.vm.box_url parameter to point to your current box. This address could be a URI or the path to the box in your host machine for example “c:\virtualmachines\devel\machineboxname.box”.
Vagrant is so powerful that we have done no more than skim the surface of these topics.
If you just want to re-package a .box file that you were given, then you can try "vagrant box add " where the address is a URL or a physical address. Once that box is added, you can call "vagrant init" to generate your Vagrantfile and "vagrant up" to make a virtual machine based on your friend's base box. The folder that you're currently in then becomes the place where you do all future vagrant commands for this virtual machine.

Resources