如何在Vagrant Box上使用Chef-solo设置部署用户?

时间:2013-02-24 12:01:43

标签: chef vagrant

在我的Vagrantfile中,我有:

  config.vm.network :hostonly, "192.168.1.20"

现在,我如何设置我的用户

ssh  deploy@192.168.1.20

开箱即用吗? (= vagrant up后和Chef-solo配置?)

1 个答案:

答案 0 :(得分:2)

您需要通过托管您的vagrantbox的机器的IP ssh到您的vagrantbox。但是你使用的是不同于标准ssh端口22的端口号。通常,vagrant为你的流浪者盒子的ssh端口22设置一个端口,到主机机器的端口2222

ssh -p 2222 deploy@localhost

ssh -p 2222 deploy@<port of your host machine>

当然,您需要让厨师在您的一本食谱中创建部署用户,如下所述:http://wiki.opscode.com/display/chef/Resources#Resources-User

user "deploy" do
 comment "Deploy User"
 uid 1000
 gid "users"
 home "/home/deploy"
 shell "/bin/sh"
 password "$1$JJsvHslV$szsCjVEroftprNn4JHtDi."
end