1+ %w( vagrant-hostmanager vagrant-auto_network vagrant-nfs_guest ) . each do |plugin |
2+ unless Vagrant . has_plugin? ( plugin )
3+ raise 'In order to use this box, you must install plugin: ' + plugin
4+ end
5+ end
6+
7+ require_relative 'vagrant/inline/config'
8+ require_relative 'vagrant/inline/nfs-plugin'
9+
10+ # Define Vagrantfile configuration options
11+ VagrantApp ::Config . option ( :varnish , false ) # If varnish needs to be enabled
12+ . option ( :profiler , false ) # Is profiler needs to be installed
13+ . option ( :developer , false ) # Is developer mode should be enabled
14+ . option ( :magento2 , false ) # Is it Magento 2.0
15+ . option ( :install , false ) # Install Magento? (for now only 2.0)
16+ . option ( :shell , false ) # Shell script?
17+ . option ( :php7 , false ) # Is it PHP7?
18+ . option ( :name , '' ) # Name
19+ . option ( :hostname , '' ) # Hostname
20+ . option ( :domains , [ ] ) # Domain list
21+ . option ( :cpu , 1 ) # Number of dedicated CPU
22+ . option ( :memory , 1024 ) # Number of dedicated memory in MB
23+ . option ( :user , 'app' ) # User name for share
24+ . option ( :group , 'app' ) # Group name for share
25+ . option ( :uid , Process . euid ) # User ID for mapping
26+ . option ( :gid , Process . egid ) # Group ID for mapping
27+ . option ( :directory , 'server' ) # Directory to be used as mount on host machine
28+ . option ( :network , '33.33.33.0/24' ) # Directory to be used as mount on host machine
29+
30+ Vagrant . configure ( "2" ) do |config |
31+
32+ # Prepare configuration and setup shell scripts for it
33+ current_file = Pathname . new ( __FILE__ )
34+ box_config = VagrantApp ::Config . new
35+
36+ # Base hypernode provisioner
37+ box_config . shell_add ( 'hypernode.sh' )
38+ . shell_add ( 'composer.sh' ) # Composer installer
39+ . shell_add ( 'nfs.sh' ) # NFS server modifications to have proper permissions
40+ . shell_add ( 'developer.sh' , :developer ) # Developer mode setting, depends on :developer configuration flag
41+ . shell_add ( 'profiler.sh' , :profiler ) # Profiler installer, depends on :profiler configuration flag
42+ . shell_add ( 'disable-varnish.sh' , :varnish , true ) # Varnish disabler, depends on :varnish inverted flag
43+ . shell_add ( 'magento2.sh' , :magento2 ) # M2 Nginx Config Flag, depends on :magento2 flag
44+ . shell_add ( 'magento2-install.sh' , [ :magento2 , :install ] ) # M2 Installer, depends on :magento2 and :install
45+ . shell_add ( 'magento2-developer.sh' , [ :magento2 , :install , :developer ] ) # M2 Developer options, depends on :magento2, :install, :developer
46+ . shell_add ( 'shell.sh' , :shell ) # Fish shell installer, depends on :shell flag
47+ . shell_add ( 'hello.sh' ) # Final message with connection instructions
48+
49+ # Loads config.rb from the same directory where Vagrantfile is in
50+ box_config . load ( File . join ( current_file . dirname , 'config.rb.dst' ) )
51+ box_config . load ( File . join ( current_file . dirname , 'config.rb' ) )
52+
53+ AutoNetwork . default_pool = box_config . get ( :network )
54+
55+ if box_config . flag? ( :php7 )
56+ config . vm . box = 'hypernode_php7'
57+ config . vm . box_url = 'http://vagrant.hypernode.com/customer/php7/catalog.json'
58+ else
59+ config . vm . box = 'hypernode_php5'
60+ config . vm . box_url = 'http://vagrant.hypernode.com/customer/php5/catalog.json'
61+ end
62+
63+ config . ssh . forward_agent = true
64+
65+ config . vm . provider :virtualbox do |v , o |
66+ v . memory = box_config . get ( :memory )
67+ v . cpus = box_config . get ( :cpu )
68+ end
69+
70+ config . vm . provider :lxc do |lxc |
71+ lxc . customize 'cgroup.memory.limit_in_bytes' , box_config . get ( :memory ) . to_s + 'M'
72+ end
73+
74+ # Disable default /vagrant mount as we use custom user for box
75+ config . vm . synced_folder '.' , '/vagrant/' , disabled : true
76+
77+ config . vm . synced_folder box_config . get ( :directory ) , '/data/web' , type : 'nfs_guest' , create : true ,
78+ linux__nfs_options : %w( rw no_subtree_check all_squash insecure async ) ,
79+ map_uid : box_config . get ( :uid ) . to_s ,
80+ map_gid : box_config . get ( :gid ) . to_s ,
81+ owner : box_config . get ( :user ) ,
82+ group : box_config . get ( :group )
83+
84+ box_config . shell_list . each do |file |
85+ config . vm . provision 'shell' , path : 'vagrant/provisioning/' + file , env : {
86+ VAGRANT_UID : box_config . get ( :uid ) . to_s ,
87+ VAGRANT_GID : box_config . get ( :gid ) . to_s ,
88+ VAGRANT_USER : box_config . get ( :user ) ,
89+ VAGRANT_GROUP : box_config . get ( :group ) ,
90+ VAGRANT_HOSTNAME : box_config . get ( :hostname )
91+ }
92+ end
93+
94+ config . hostmanager . enabled = true
95+ config . hostmanager . manage_host = true
96+ config . hostmanager . ignore_private_ip = false
97+ config . hostmanager . include_offline = true
98+
99+ config . vm . define 'hypernode' do |node |
100+ node . vm . hostname = box_config . get ( :hostname )
101+ node . vm . network :private_network , auto_network : true
102+ node . hostmanager . aliases = box_config . get ( :domains )
103+ end
104+
105+ end
0 commit comments