VirtualBox + Vagrant + Ansible(ansible_local)で構築したrubyの開発環境を開発メンバー(windows環境)に使ってもらったところ、共有フォルダ内に作成したファイルがホストOS/ゲストOS間で参照出来ないという現象が発生した。vagrant-vbguestプラグインをインストールしても解消されず。vagrant起動時のログを見せてもらうと

C:\Path\to\project>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> default: have version '20160816.0.0'. The latest is version '20160919.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 3000 (guest) => 3000 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.36
    default: VirtualBox Version: 5.1
==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'

Stdout from the command:



Stderr from the command:

/usr/bin/env: bash: No such file or directory
/etc/profile.d/rbenv.sh: line 2: $'\r': command not found
stdin: is not a tty
bash: line 2: sed: command not found
bash: line 2: grep: command not found

こんな感じでPATH設定がおかしくなっていてGeustAdditionsを取得&ビルドする所でコケている模様。ansibleでrbenvをインストールする際に

- name: add rbenv path to bash_profile
  copy: src=files/rbenv.sh dest=/etc/profile.d/rbenv.sh

としてPATHを追加しているが該当ファイルの記述には問題なく、また別のwindows環境では再現しなかった。

/etc/profile.d/rbenv.sh: line 2: $'\r': command not found

の \r ってのが気になって調べてみたら、windows環境のgitで改行コードの自動変換が設定されていてansibleコピー元のシェルスクリプトの改行コードがCRLFに変換されていたのが原因だった。

> git config --global core.autoCRLF false

で改行コードの自動変換を無効に設定した後、開発環境のリポジトリをクローンし直して作業してもらって解決した。