dev/Vagrantfile
changeset 28 b0b56e0f8c7f
parent 19 eadaf0b8f02e
child 406 cf0f23803a53
equal deleted inserted replaced
27:a2342f26c9de 28:b0b56e0f8c7f
     1 # -*- mode: ruby -*-
     1 # -*- mode: ruby -*-
     2 # vi: set ft=ruby :
     2 # vi: set ft=ruby :
     3 
       
     4 require 'yaml'
     3 require 'yaml'
     5 
     4 
     6 custom_file_path = File.join(__dir__, (ENV['SYSCONFIG'] || 'custom.yaml'))
     5 custom_file_path = File.join(__dir__, (ENV['SYSCONFIG'] || 'custom.yaml'))
     7 
     6 
     8 context = (File.exist?(custom_file_path)?YAML::load_file(custom_file_path):{}) || {}
     7 context = (File.exist?(custom_file_path)?YAML::load_file(custom_file_path):{}) || {}
     9 
       
    10 
     8 
    11 # All Vagrant configuration is done below. The "2" in Vagrant.configure
     9 # All Vagrant configuration is done below. The "2" in Vagrant.configure
    12 # configures the configuration version (we support older styles for
    10 # configures the configuration version (we support older styles for
    13 # backwards compatibility). Please don't change it unless you know what
    11 # backwards compatibility). Please don't change it unless you know what
    14 # you're doing.
    12 # you're doing.
    17   # For a complete reference, please see the online documentation at
    15   # For a complete reference, please see the online documentation at
    18   # https://docs.vagrantup.com.
    16   # https://docs.vagrantup.com.
    19 
    17 
    20   # Every Vagrant development environment requires a box. You can search for
    18   # Every Vagrant development environment requires a box. You can search for
    21   # boxes at https://atlas.hashicorp.com/search.
    19   # boxes at https://atlas.hashicorp.com/search.
    22   config.vm.box = "puppetlabs/centos-6.6-64-nocm"
    20   #config.vm.box = "centos/7"
       
    21   config.vm.box = "puppetlabs/centos-7.0-64-nocm"
    23 
    22 
    24   # Disable automatic box update checking. If you disable this, then
    23   # Disable automatic box update checking. If you disable this, then
    25   # boxes will only be checked for updates when the user runs
    24   # boxes will only be checked for updates when the user runs
    26   # `vagrant box outdated`. This is not recommended.
    25   # `vagrant box outdated`. This is not recommended.
    27   # config.vm.box_check_update = false
    26   # config.vm.box_check_update = false
    28 
    27 
       
    28   # Create a private network, which allows host-only access to the machine
       
    29   # using a specific IP.
       
    30   # config.vm.network "private_network", ip: "192.168.33.10"
       
    31   config.vm.network :private_network, ip: (ENV['VM_IP'] || context['vm_ip'] || "172.16.1.6")
       
    32 
    29   # Create a forwarded port mapping which allows access to a specific port
    33   # 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,
    34   # 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.
    35   # accessing "localhost:8080" will access port 80 on the guest machine.
    32   # config.vm.network "forwarded_port", guest: 80, host: 8080
    36   # 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 = {
    37   default_ports = {
    36     80   => 40000,
    38     80   => 40000,
    37     443  => 44300,
    39     443  => 44300,
    38     3306 => 33060,
    40     3306 => 33060,
    39     5432 => 54320,
    41     5432 => 54320,
    43   # Use Default Port Forwarding Unless Overridden
    45   # Use Default Port Forwarding Unless Overridden
    44   default_ports.each do |guest, host|
    46   default_ports.each do |guest, host|
    45     config.vm.network "forwarded_port", guest: guest, host: host
    47     config.vm.network "forwarded_port", guest: guest, host: host
    46   end
    48   end
    47 
    49 
    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.
    50   # Create a public network, which generally matched to bridged network.
    54   # Bridged networks make the machine appear as another physical device on
    51   # Bridged networks make the machine appear as another physical device on
    55   # your network.
    52   # your network.
    56   # config.vm.network "public_network"
    53   # config.vm.network "public_network"
    57 
    54 
    58   # Share an additional folder to the guest VM. The first argument is
    55   # 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
    56   # 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
    57   # the path on the guest to mount the folder. And the optional third
    61   # argument is a set of non-required options.
    58   # argument is a set of non-required options.
    62   config.vm.synced_folder "../server", "/code", id: "code-root",
    59   # config.vm.synced_folder "../data", "/vagrant_data"
    63     owner: "vagrant",
    60   # config.vm.synced_folder "../server/src", "/var/www/corpus", id: "code-root",
    64     group: 498,
    61   #   owner: "vagrant",
    65     mount_options: ["dmode=775,fmode=664"]
    62   #   group: 498,
       
    63   #   mount_options: ["dmode=775,fmode=664"]
       
    64 
    66 
    65 
    67   # Provider-specific configuration so you can fine-tune various
    66   # Provider-specific configuration so you can fine-tune various
    68   # backing providers for Vagrant. These expose provider-specific options.
    67   # backing providers for Vagrant. These expose provider-specific options.
    69   # Example for VirtualBox:
    68   # Example for VirtualBox:
    70   #
    69   #
    73   #   vb.gui = true
    72   #   vb.gui = true
    74   #
    73   #
    75   #   # Customize the amount of memory on the VM:
    74   #   # Customize the amount of memory on the VM:
    76   #   vb.memory = "1024"
    75   #   vb.memory = "1024"
    77   # end
    76   # end
    78   #
       
    79   config.vm.provider "virtualbox" do |v|
    77   config.vm.provider "virtualbox" do |v|
    80     v.memory = 1024
    78     v.memory = 1024
    81     v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    79     v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    82   end
    80   end
    83 
    81 
       
    82   #
    84   # View the documentation for the provider you are using for more
    83   # View the documentation for the provider you are using for more
    85   # information on available options.
    84   # information on available options.
    86 
    85 
    87   # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
    86   # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
    88   # such as FTP and Heroku are also available. See the documentation at
    87   # such as FTP and Heroku are also available. See the documentation at
    96   # documentation for more information about their specific syntax and use.
    95   # documentation for more information about their specific syntax and use.
    97   # config.vm.provision "shell", inline: <<-SHELL
    96   # config.vm.provision "shell", inline: <<-SHELL
    98   #   sudo apt-get update
    97   #   sudo apt-get update
    99   #   sudo apt-get install -y apache2
    98   #   sudo apt-get install -y apache2
   100   # SHELL
    99   # SHELL
       
   100   config.vm.provision :shell do |shell|
       
   101     #initialize puppet
       
   102     shell.name = "puppet_initialize"
       
   103     shell.path = "provisioning/bootstrap-puppet.sh"
       
   104   end
   101 
   105 
   102   config.vm.provision :shell do |shell|
   106   config.vm.provision :shell do |shell|
   103     shell.inline = "getent group nginx || groupadd -g 498 nginx;"
   107     #initialize puppet
       
   108     shell.name = "system_initialize"
       
   109     shell.inline = "[ ! -d '/tmp/vagrant-puppet' ] && mkdir -p '/tmp/vagrant-puppet' || :;"
   104   end
   110   end
   105 
   111 
   106   config.vm.provision "ansible" do |ansible|
   112   config.vm.provision :puppet do |puppet|
   107     ansible.playbook = "provisioning/playbook.yml"
   113       puppet.manifests_path = "provisioning"
   108     ansible.extra_vars = {
   114       puppet.manifest_file = "default.pp"
   109         site_name: "corpus-parole.local"
   115       puppet.module_path = "provisioning/modules"
   110     }
   116       puppet.hiera_config_path = "provisioning/hiera.yaml"
   111     ansible.sudo = true
   117       puppet.working_directory = "/vagrant/provisioning/"
       
   118       puppet.options = "--verbose --debug"
   112   end
   119   end
   113 
   120 
   114 end
   121 end