当我尝试执行mount模块时,我的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 (...)
Vagrantfile:
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 playbook:
- 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
然后用“laptop”替换mount名称参数“192.168.33.1”,但是也没有修复它。有谁看到我做错了什么?
感谢。
答案 0 :(得分:2)
你的Ansible剧本似乎有几个问题。最后一部分不是有效的YAML,但更重要的是,您的坐骑中的public static void print(String prefix, String remaining, int k) {
if (k == 0) {
StdOut.println(prefix);
return;
}
if (remaining.length() == 0) return;
print(prefix + remaining.charAt(0), remaining.substring(1), k-1);
print(prefix, remaining.substring(1), k);
}
public static void main(String[] args) {
String s = "abcdef";
int k = 3;
print("", s, k);
}
和name
是相反的。文档声明" src
is device to be mounted on name"。名称也应该是挂载点的路径。这是解决这些问题的剧本......
src
如果您进行了这些更改并注释掉了Vagrantfile中的- 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
,我认为它会以您想要的方式运行。