dcosson / vagrant-unison2

Vagrant plugin to sync local files to VM using Unison over SSH
MIT License
50 stars 8 forks source link

Allow configuration of ssh user, host and port #3

Closed flynfish closed 8 years ago

flynfish commented 8 years ago

This allows us to configure the vagrant user, host and port.

Also, it would be helpful if the issues were turned on in this repo so people could discuss issues and report bugs.

dcosson commented 8 years ago

Cool, I turned on issues.

Did you close this on purpose? Feel free to re-open if you still want it to be merged.

flynfish commented 8 years ago

@dcosson Thanks for turning on issues! I closed it because I was running into an error when unison was trying to sync from the VM back to the host. After research, I think it's because the brew'd unison I'm using and the unison I installed on the VM were built with different ocaml versions :-1:

Anyways, thoughts on this PR?

dcosson commented 8 years ago

It looks good.

Just out of curiousity, what configuration are you using that you have a different ip address and port? I've really only used Vagrant locally with Virtualbox & Ubuntu so the defaults worked fine for me.

flynfish commented 8 years ago

The default vagrant user is only used on initial machine provision. We use an ansible playbook to configure the VM which sets up a new 'deploy' user for ssh'ing and installing all other reqs. Because of that the default vagrant ssh user no longer works for us. Here is what we do:

config.vm.define "dev" do |dev|
    dev.vm.hostname = 'dev'
    dev.vm.network 'forwarded_port', guest: 3000, host: 3000

    config.unison.host_folder = "../"  #relative to the folder your Vagrantfile is in
    config.unison.guest_folder = "/var/www/" #relative to the vagrant home folder -> /home/vagrant
    config.unison.ignore = "Name {.DS_Store,.git,.vagrant,node_modules,tmp,*.log,*.tags}"
    config.unison.ssh_host = "10.0.4.19"
    config.unison.ssh_user = "deploy"
    config.unison.ssh_port = 22

    dev.vm.synced_folder ".", "/vagrant", disabled: true

    #IP matches the one in hosts/development/inventory file
    dev.vm.network "private_network", ip: "10.0.4.19"

    dev.vm.provision 'ansible' do | a |
      a.inventory_path = 'hosts/development/inventory'
      a.extra_vars = { ansible_ssh_user: 'vagrant' }
      a.playbook = 'ubuntu_prep.yml'
      a.verbose  = 'v'
      a.vault_password_file = "~/.vault_pass.txt"
      a.limit = 'all'
    end
  end
dcosson commented 8 years ago

Cool. This is working for me and looks good, merging.