From a3f50eb8b5886b09651ed80b613a690aafea5042 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 5 May 2014 11:51:45 -0400 Subject: Let the sync type be configurable. Useful for setups where getting nfs sync working is a PITA. --- vagrant/gluster/Vagrantfile | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/vagrant/gluster/Vagrantfile b/vagrant/gluster/Vagrantfile index fc509d4..1ed3a24 100644 --- a/vagrant/gluster/Vagrantfile +++ b/vagrant/gluster/Vagrantfile @@ -72,6 +72,7 @@ replica = 1 # default replica count clients = 1 # default number of gluster clients to build layout = '' # default brick layout setgroup = '' # default setgroup value +sync = 'rsync' # default sync type cachier = false # default cachier usage # @@ -91,6 +92,7 @@ if File.exist?(f) clients = settings[:clients] layout = settings[:layout] setgroup = settings[:setgroup] + sync = settings[:sync] cachier = settings[:cachier] end @@ -152,6 +154,12 @@ while skip < ARGV.length setgroup = v.to_s # set gluster setgroup + elsif ARGV[skip].start_with?(arg='--gluster-sync=') + v = ARGV.delete_at(skip).dup + v.slice! arg + + sync = v.to_s # set sync type + elsif ARGV[skip].start_with?(arg='--gluster-cachier=') v = ARGV.delete_at(skip).dup v.slice! arg @@ -178,6 +186,7 @@ settings = { :clients => clients, :layout => layout, :setgroup => setgroup, + :sync => sync, :cachier => cachier } File.open(f, 'w') do |file| @@ -222,7 +231,7 @@ end # XXX: workaround for: https://github.com/mitchellh/vagrant/issues/2447 # only run on 'vagrant init' or if it's the first time running vagrant -if (ARGV.length > 0 and ARGV[0] == 'init') or not(File.exist?(f)) +if sync == 'nfs' and ((ARGV.length > 0 and ARGV[0] == 'init') or not(File.exist?(f))) `sudo systemctl restart nfs-server` `firewall-cmd --permanent --zone public --add-service mountd` `firewall-cmd --permanent --zone public --add-service rpc-bind` @@ -243,6 +252,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # TODO: this box should be GPG signed config.vm.box_url = 'https://download.gluster.org/pub/gluster/purpleidea/vagrant/centos-6/centos-6.box' + # + # sync type + # + config.vm.synced_folder './', '/vagrant', type: sync # nfs, rsync + # # cache # @@ -257,11 +271,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if not ARGV.include?('--no-parallel') # when running in parallel, config.cache.scope = :machine # use the per machine cache end - config.cache.enable_nfs = true # sets nfs => true on the synced_folder - # the nolock option is required, otherwise the NFSv3 client will try to - # access the NLM sideband protocol to lock files needed for /var/cache/ - # all of this can be avoided by using NFSv4 everywhere. die NFSv3, die! - config.cache.mount_options = ['rw', 'vers=3', 'tcp', 'nolock'] + if sync == 'nfs' # TODO: support other sync types here... + config.cache.enable_nfs = true # sets nfs => true on the synced_folder + # the nolock option is required, otherwise the NFSv3 client will try to + # access the NLM sideband protocol to lock files needed for /var/cache/ + # all of this can be avoided by using NFSv4 everywhere. die NFSv3, die! + config.cache.mount_options = ['rw', 'vers=3', 'tcp', 'nolock'] + end end # @@ -346,6 +362,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 'vagrant_gluster_firewall' => firewall ? 'true' : 'false', 'vagrant_gluster_allow' => (1..count).map{|z| range[offset+z].to_s}.join(','), } + puppet.synced_folder_type = sync end vm.vm.provider :libvirt do |libvirt| @@ -531,11 +548,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end end - # - # misc - # - #config.vm.synced_folder "hacking/", "/vagrant_hacking", :nfs => true, :mount_options => ['rw', 'vers=3', 'tcp'] - # # libvirt # -- cgit