2017 © Pedro Peláez

library vagrantfile

Vagrant file generator.



Vagrant file generator.

  • Monday, March 13, 2017
  • by smalot
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown


Vagrantfile generator

Helper to easily create Vagrantfile., (*1)


include 'vendor/autoload.php';

use Smalot\Vagrant\Generator\Machine\Network\ForwardedPort;
use Smalot\Vagrant\Generator\Machine\Network\PrivateNetwork;
use Smalot\Vagrant\Generator\Machine\Network\PublicNetwork;
use Smalot\Vagrant\Generator\Provision\Ansible;
use Smalot\Vagrant\Generator\Vagrantfile;

$vagrantfile = new Vagrantfile();



$forwardedPort = new ForwardedPort();

$privateNetwork = new PrivateNetwork();

$publicNetwork = new PublicNetwork();
$publicNetwork->addBridge('en1: Wi-Fi (AirPort)');
$publicNetwork->addBridge('en6: Broadcom NetXtreme Gigabit Ethernet Controller');

$ansible = new Ansible();

echo $vagrantfile->dump();

This sample code will generate this:, (*2)

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    # The most common configuration options are documented and commented below.
    # For a complete reference, please see the online documentation at
    # https://docs.vagrantup.com.

    config.vm.box = "bento/ubuntu-16.04"
    config.vm.box_check_update = false

    # Create a forwarded port mapping which allows access to a specific port
    # within the machine from a port on the host machine.
    config.vm.network "ForwardedPorted_port", guest: 80, host: 8081

    # Create a private network, which allows host-only access to the machine using
    # a specific IP.
    config.vm.network "private_network", dhcp: true

    # Create a public network, which generally matched to bridged network. Bridged
    # networks make the machine appear as another physical device on your network.
    config.vm.network "public_network", bridge: ["en1: Wi-Fi (AirPort)", "en6: Broadcom NetXtreme Gigabit Ethernet Controller"]

    # View the documentation for the provider you are using for more information
    # on available options.
    config.vm.provision "ansible" do |ansible|
        ansible.verbose = "v"
        ansible.playbook = "playbook.yml"

    config.ssh.username = "ubuntu"
    config.ssh.password = "password"


The Versions

13/03 2017



Vagrant file generator.

  Sources   Download


generator vagrant vagrantfile