Getting vagrant synced folders to work on windows with openstack - windows

I'm using vagrant-openstack-plugin to handle openstack integration and it uses a builtin rsync synced folder provider, I can't get it to use the plugin I specify (winrm) even by hacking the code a little.
For the record I can get rsync to work (with winsshd and cwrsync and a junction point from C:\cygdrive\C to C:\), but it's really gnarly.
I'm open to non-ssh/non-rsync synced folder options for windows (NFS? SMB only works if the host is Windows), but I need the openstack plugin to respect my choice of synced folder plugin first.

Related

How can I retain shared folders when cloning VMs using virtualbox and vagrant

First, I am on a Mac. Second, I have a virtualbox VM which was created using vagrant and which uses a shared folder to easily pass files back and forth, etc.
I would now like to clone this VM from a particular state so that I can upgrade an application on it and move forward with it. The issue is that the only way I know of to use shared folders here is to start the box using vagrant up (this makes sense as vagrant mounts the folders as part of its boot process); however, using vagrant up always triggers the original VM.
Is there a way to create a clone of a VM using Virtual Box and then to be able to use shared folders so I can easily copy files to and from the host and guest via ssh?
Did some more researching and found that I can mount a shared folder in a clone in the same way I can with the original virtualbox VM using:
mount -t vboxsf -o rw,uid=33,gid=33 <shared_folder_name> <guest_folder>
Note that the uid and gid specified here relate only to Debian-based systems. CentOS IDs are different.
For more on the technique and for solutions for CentOS boxes, see here: http://jimmybonney.com/articles/configure_virtualbox_shared_folder_apache_virtual_host/
I've tried the steps in the above article to allow for auto mounting the shared folder when the VM boots, but I've had no success. As a work-around (which I find acceptable for now), I created an alias in my .bashrc file which seems to work fine.
I would now like to clone this VM from a particular state so that I can upgrade an application on it and move forward with it
one thing you can look is vagrant snapshot
Snapshot works with VirtualBox provider to take a snapshot of your VM at the particular point of time when snapshot is taken. You can then continue working on your VM and when needed you can easily recover from a previous snapshot

How to automate rsync in OS X with remote server

My remote Server is samba server, which is accessible by both Mac and Windows machine.I created a common folder in Samba server. I want my local folder to be in sync with the common folder on my samba Server. Because when internet connection is lost i am unable to access the files copied to common folder.For that sake i want to sync my local folder with it.
My goals are:
When i remove files from local folder,it should get removed in common folder in samba server
Similarly when i modify or delete files in common folder, it should get reflected in local folder of my machine.
I tried rsync:
rsync --progress -avzC --stats --force Source root#remoteserver:/path
But how do I automate syncing from both sides?
Note: For this i can rely on Dropbox, Boxsync or some cloud share app support. But i want to implement my own functionality, I don't want to rely on Third party API.

Vagrant Virtualbox Openstack - or is there a better way?

Current Steup
Using a Vagrant/Virtualbox image for development
Vagrant file and php code are both checked into a git repo
When a new user joins the project they pull down the git repo and type vagrant up
When we deploy to our "dev production" server we are on a CentOS 7 machine that has virtual box and vagrant and we just run the vagrant image
Future Setup
We are moving towards an OpenStack "cloud" and are wondering how to best integrate this current setup into the workflow
As I understand it OpenStack allows you to create individual VMs - which sounds cool because on one hand we could then launch our VM's, but the problem is we are taking advantage of Vagrant/Virtual Box's "mapping" functionality so that we are mounting /var/www/html to a /html directory in the folder we run vagrant out of. I assume this is not possible with OpenStack - and was wondering whether there is a specified best practice for how to handle this situation.
Approach
The only approach i can think of is to:
Install a VM on OpenStack that runs Centos7 and then inside that VM run Vagrant/VirtualBox (this seems bonkers)
But then we have VM inside a VM inside a VM and that just doesn't seem efficient.
Is there a tool - or guide - or guidance how to work with both a local vagrant image and the cloud? It seems like there may not be as easy a mapping as I initially though.
Thanks
It sounds like you want to keep using vagrant, presumably using https://github.com/ggiamarchi/vagrant-openstack-provider or similar? With that assumption, the way to do this which is probably the smallest iteration from your current setup is just to use an rsync synced folder - see https://www.vagrantup.com/docs/synced-folders/rsync.html. You should be able to something like this:
config.vm.synced_folder "html/", "/var/www/html", type: 'rsync'
Check the rest of that rsync page though -- depending on your ssh user, you might need to use the --rsync-path option.
NB - you don't mention whether you vagrant host is running windows or linux etc. If you're on windows then I tend to use cygwin, though I expect you can otherwise find some rsync.exe to use.
If you can free yourself from the vagrant pre-requisite then there are many solutions, but the above should be a quick win from where you are now.

Is there a way to unsync a subfolder in Vagrant?

There are few subfolders in my project folder that wouldn't need to be synced to the guest machine. (In particular the .git folder, which contains >800 files.) Is there a way to unsync subfolders of a synced folder in Vagrant? Or how should I prevent unneeded folders from being synced?
Disabling sync this way doesn't seem to work, when /vagrant/ is synced by default:
config.vm.synced_folder "www/kisa/.git/", "/vagrant/www/kisa/.git/", disabled: true
Normally (with vboxsf, vmhgfs, NFS, ...) the syncing is done by mounting the specified directory from the host to the guest. For performance reasons there should be no need to prevent some content from "syncing", as the data is not transferred unless you access it from the guest. If you write the data on the guest but don't want to sync it back to the host, easiest is to write it somewhere else. =)
The upcoming Vagrant 1.5 will include rsync synced folders which will support rsync__exclude option. Some cloud provider plugins (aws, digital_ocean, ..) already use rsync, but support for excluding depends on the provider. In some cases you just have to sync only the wanted folders separately. You can disable the default sync with
config.vm.synced_folder ".", "/vagrant", disabled: true
I can't pretend to understand this, but the method shown at this. seems to work for me for a Linux (Ubuntu) guest on a windows 7 host.
I wanted to use it for exactly what he describes - to exclude a node_modules directory from being shared.
In case the link disappears the gist is:
$ mkdir ~/vagrant_node_modules
$ sudo mount --bind ~/vagrant_node_modules /vagrant/node_modules
so that /vagrant is shared but /vagrant/node_modules is not.
Someone more knowledgeable than me might know if there are problems with this.

Convert Unicode decomposition when transferring files to web server

I am doing website development on OS X, and fairly often I find myself in situations where I move some part of a live website (running Linux/LAMP) to a development server running on my own machine. One such instance involves downloading images (user generated content, e.g. via ftp download), processing them in one way or another and the putting them back on the production site.
The image files involved, being created in a Linux machine, appears to have their filenames encoded in UTF-8 using NFC decomposition. OS X's HFS+ file system on the other hand does not allow NFC decomposed filenames and converts into NFD. However, once I am done and want to upload the files their names will now be using NFD decompositions, since Linux supports them both. As a result, the newly uploaded (and in some cases replaced) files will not be accessible at the expected URL.
I'm looking for a way to change the UTF decomposition of the files during (preferably) or after (convmv looks like a good option, but I don't have sufficient permissions on this server it's not possible in this particular case) transfer, since I'm guessing it's impossible doing it beforehand. I've tried FTP-upload using Transmit and rsync (using a deploy script a normally use) to no avail. the --iconv option in rsync seemed ideal, but unfortunately my server running rsync 2.6.9 did not recognize it.
I'm guessing quite a few people are having similar issues, I'll be happy to hear any solution or workaround!
UPDATE: In this case I ended up rsyncing the files to a virtual machine running Ubuntu, running convmv on them on there, and then rsyncing again to my staging server. While this works fairly well it is a bit time consuming. Perhaps it would be possible to mount an ext file system on OS X and just store the files there instead, using their original NFC decomposed file names?
Also, to avoid this problems all together on future WordPress installs, which was my use case, you could add a simple add_filter('sanitize_file_name', 'remove_accents'); before uploading any files and you should be fine.
It seems that rsync --iconv is the best solution, as you can transfer the files and transcode the names all in one step. You just need to convince your host to upgrade their rsync. Given that the --iconv feature was introduced in rsync 3.0.0, which was released in 2008, it's a bit odd that your host is still running rsync 2.6.9.
If you can't convince your host to install an up-to-date rsync, you could compile your own rsync, upload it somewhere like ~/bin on the server, and add that to your path before the system installed rsync. Then you should be able to use the --iconv option. This should work as long as you are using rsync over SSH (the default), not the rsync daemon; because rsync over SSH works by SSHing to the remote machine, and running rsync --server with the same options that you passed to your local rsync.
Or you could find a host that has up-to-date tools and Perl installed.
Currently I'm using rsync --iconv like this:
Given Linux server and OS X machine:
Copying files from server to machine
You should execute this command from server (it won't work from OS X):
rsync --iconv=UTF-8,UTF-8-MAC /home/username/path/on/server/ 'username#your.ip.address.here:/Users/username/path/on/machine/'
Copying files from machine to server
You should execute this command from machine:
rsync --iconv=UTF-8-MAC,UTF-8 /Users/username/path/on/machine/ 'username#server.ip.address.here:/home/username/path/on/server/'

Resources