Vagrant 为什么赢了';可迁移装载流浪远程NFS共享

Vagrant 为什么赢了';可迁移装载流浪远程NFS共享,vagrant,ansible,vagrantfile,Vagrant,Ansible,Vagrantfile,我的Ansible playbook在尝试执行装载模块时出错: Error mounting 192.168.33.1:/Users/me/playbooks/site1/website: mount.nfs: remote share not in 'host:dir' format 代码目录已装入: $ vagrant ssh -c "mount | grep http" 192.168.33.1:/Users/me/playbooks/site1/website on /srv/http

我的Ansible playbook在尝试执行装载模块时出错:

Error mounting 192.168.33.1:/Users/me/playbooks/site1/website: mount.nfs: remote share not in 'host:dir' format
代码目录已装入:

$ vagrant ssh -c "mount | grep http"
192.168.33.1:/Users/me/playbooks/site1/website on /srv/http/site1.com type nfs (...)
流浪汉档案:

Vagrant.configure("2") do |config|
  config.vm.box = "debian/jessie64"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 443, host: 8443
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.synced_folder "website/", "/srv/http/site1.com", nfs: true
end
Ansible剧本:

- name: Remount code directory
  hosts: web
  sudo: True
  tasks:
    - name: unmount website
      mount:
        name: /srv/http/site1.com
        src: srv_http_site1.com
        fstype: nfs
        state: unmounted
    - name: remount website
      mount: 
        name="192.168.33.1:/Users/me/playbooks/site1/website"
        src="srv_http_site1.com" 
        fstype=nfs 
        state=mounted
我正在运行NFS v3:

$ sudo nfsstat | grep nfs  # => Client nfs v3
我不知道为什么会这样。卸载任务将卸载文件系统,但以下装载任务失败。mount(8)手册页上说“设备可能看起来像knuth.cwi.nl:/dir”。nfs(5)手册页指出,服务器主机名可以是“虚线四路IPv4地址”。我尝试将以下行添加到我的/etc/hosts文件中:

laptop    192.168.33.1
然后将mount name参数“192.168.33.1”替换为“laptop”,但这也无法解决问题。有人知道我做错了什么吗


谢谢。

你的Ansible剧本似乎有几个问题。最后一部分不是有效的YAML,但更重要的是,挂载中的
name
src
是反向的。文件中说“是”。此外,名称应为装载点的路径。这是解决这些问题的行动手册

- name: Remount code directory
  hosts: web
  sudo: True
  tasks:
    - name: unmount website
      mount:
        name: /srv/http/site1.com
        src: 192.168.33.1:/Users/me/playbooks/site1/website
        fstype: nfs
        state: unmounted
    - name: remount website
      mount:
        name: /srv/http/site1.com
        src: 192.168.33.1:/Users/me/playbooks/site1/website
        fstype: nfs
        state: mounted

如果您进行这些更改并注释掉Vagrant文件中的
synced_文件夹
,我认为它将按照您想要的方式工作。

您的主机文件条目是向后的。应该是192.168.33.1笔记本电脑。谢谢,很好。但是现在我得到了一个“mount…不是块设备错误”,所以如果我解决了这个问题,我必须返回到这个问题。我还想知道为什么你要在你的主机上挂载/卸载一个目录,这个目录已经设置为与Vagrant同步的文件夹。Ansible playbook似乎是多余的,但我可能遗漏了一些东西。原因是我希望共享文件夹由在我的prod服务器上拥有它的同一组拥有。但是当Vagrant创建同步文件夹时,我无法分配该所有权,因为该组不存在。我可以创建组并在配置脚本中重新装载它,但在执行ups和重新加载时,我必须始终添加--provision。如果我使用provision的“run:always”,那么我必须记住这样做——如果我不想让它运行,就不要使用provision。这很难看,所以我想我应该在我的剧本中试着这么做,但很明显这不起作用。