Vagrant file generator.

dev-master 2017-03-13 16:03 UTC

This package is not auto-updated.

Last update: 2021-02-24 03:23:18 UTC


Helper to easily create Vagrantfile.


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:

# -*- 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
    # = "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. "ForwardedPorted_port", guest: 80, host: 8081

    # Create a private network, which allows host-only access to the machine using
    # a specific IP. "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. "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"