dev/Vagrantfile
changeset 1 01a844d292ac
child 4 f55970e41793
equal deleted inserted replaced
0:279124b91971 1:01a844d292ac
       
     1 # -*- mode: ruby -*-
       
     2 # vi: set ft=ruby :
       
     3 
       
     4 require 'yaml'
       
     5 
       
     6 custom_file_path = File.join(__dir__, (ENV['SYSCONFIG'] || 'custom.yaml'))
       
     7 
       
     8 context = (File.exist?(custom_file_path)?YAML::load_file(custom_file_path):{}) || {}
       
     9 
       
    10 
       
    11 # All Vagrant configuration is done below. The "2" in Vagrant.configure
       
    12 # configures the configuration version (we support older styles for
       
    13 # backwards compatibility). Please don't change it unless you know what
       
    14 # you're doing.
       
    15 Vagrant.configure(2) do |config|
       
    16   # The most common configuration options are documented and commented below.
       
    17   # For a complete reference, please see the online documentation at
       
    18   # https://docs.vagrantup.com.
       
    19 
       
    20   # Every Vagrant development environment requires a box. You can search for
       
    21   # boxes at https://atlas.hashicorp.com/search.
       
    22   config.vm.box = "puppetlabs/centos-6.6-64-nocm"
       
    23 
       
    24   # Disable automatic box update checking. If you disable this, then
       
    25   # boxes will only be checked for updates when the user runs
       
    26   # `vagrant box outdated`. This is not recommended.
       
    27   # config.vm.box_check_update = false
       
    28 
       
    29   # Create a forwarded port mapping which allows access to a specific port
       
    30   # within the machine from a port on the host machine. In the example below,
       
    31   # accessing "localhost:8080" will access port 80 on the guest machine.
       
    32   # config.vm.network "forwarded_port", guest: 80, host: 8080
       
    33   config.vm.network :private_network, ip: (ENV['VM_IP'] || context['vm_ip'] || "172.16.1.5")
       
    34 
       
    35   default_ports = {
       
    36     80   => 40000,
       
    37     443  => 44300,
       
    38     3306 => 33060,
       
    39     5432 => 54320,
       
    40     8080 => 40400,
       
    41   }
       
    42 
       
    43   # Use Default Port Forwarding Unless Overridden
       
    44   default_ports.each do |guest, host|
       
    45     config.vm.network "forwarded_port", guest: guest, host: host
       
    46   end
       
    47 
       
    48 
       
    49   # Create a private network, which allows host-only access to the machine
       
    50   # using a specific IP.
       
    51   # config.vm.network "private_network", ip: "192.168.33.10"
       
    52 
       
    53   # Create a public network, which generally matched to bridged network.
       
    54   # Bridged networks make the machine appear as another physical device on
       
    55   # your network.
       
    56   # config.vm.network "public_network"
       
    57 
       
    58   # Share an additional folder to the guest VM. The first argument is
       
    59   # the path on the host to the actual folder. The second argument is
       
    60   # the path on the guest to mount the folder. And the optional third
       
    61   # argument is a set of non-required options.
       
    62   config.vm.synced_folder "../server", "/code", id: "code-root",
       
    63     owner: "vagrant",
       
    64     group: 498,
       
    65     mount_options: ["dmode=775,fmode=664"]
       
    66 
       
    67   # Provider-specific configuration so you can fine-tune various
       
    68   # backing providers for Vagrant. These expose provider-specific options.
       
    69   # Example for VirtualBox:
       
    70   #
       
    71   # config.vm.provider "virtualbox" do |vb|
       
    72   #   # Display the VirtualBox GUI when booting the machine
       
    73   #   vb.gui = true
       
    74   #
       
    75   #   # Customize the amount of memory on the VM:
       
    76   #   vb.memory = "1024"
       
    77   # end
       
    78   #
       
    79   config.vm.provider "virtualbox" do |v|
       
    80     v.memory = 512
       
    81   end
       
    82 
       
    83   # View the documentation for the provider you are using for more
       
    84   # information on available options.
       
    85 
       
    86   # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
       
    87   # such as FTP and Heroku are also available. See the documentation at
       
    88   # https://docs.vagrantup.com/v2/push/atlas.html for more information.
       
    89   # config.push.define "atlas" do |push|
       
    90   #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
       
    91   # end
       
    92 
       
    93   # Enable provisioning with a shell script. Additional provisioners such as
       
    94   # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
       
    95   # documentation for more information about their specific syntax and use.
       
    96   # config.vm.provision "shell", inline: <<-SHELL
       
    97   #   sudo apt-get update
       
    98   #   sudo apt-get install -y apache2
       
    99   # SHELL
       
   100 
       
   101   config.vm.provision :shell do |shell|
       
   102     shell.inline = "getent group nginx || groupadd -g 498 nginx;"
       
   103   end
       
   104 
       
   105   config.vm.provision "ansible" do |ansible|
       
   106     ansible.playbook = "provisioning/playbook.yml"
       
   107     ansible.sudo = true
       
   108   end
       
   109 
       
   110 end