[英]Is there a way to deploy into a vagrant VM using Capistrano?
I'd like to setup a vagrant instance outside of my project directory.我想在我的项目目录之外设置一个 vagrant 实例。 Is there a way to deploy rails into the vagrant VM with capistrano as I would to my real production host?
有没有办法像我在真正的生产主机上那样使用 capistrano 将 rails 部署到 vagrant VM 中?
I'm trying to use server as "localhost" but I get:我正在尝试将服务器用作“本地主机”,但我得到:
connection failed for: localhost (Errno::ECONNREFUSED: Connection refused - connect(2))
You can also feed Vagrant's SSH options to Capistrano (most of the :ssh_options
go directly to Net::SSH, http://net-ssh.github.com/ssh/v1/chapter-2.html , see "Options") so there is no need to mess your real ~/.ssh/config 你也可以将Vagrant的SSH选项提供给Capistrano(大部分
:ssh_options
直接转到Net :: SSH, http :ssh_options
,参见“选项”)所以没有必要弄乱你的真实〜/ .ssh / config
set :user, 'vagrant'
set :ssh_options, {port: 2222, keys: ['~/.vagrant.d/insecure_private_key']}
role :web, "localhost"
...
(Of course, you shouldn't really be using the insecure_private_key
or the default root/vagrant passwords unless properly firewalled, but the principle remains the same.) (当然,你不应该使用
insecure_private_key
或默认的root / vagrant密码,除非适当防火墙,但原则保持不变。)
I figured it out. 我想到了。 In case others care to know:
如果其他人想知道:
$ vagrant ssh
) and ran ifconfig
to get my IP address. $ vagrant ssh
)并运行ifconfig
来获取我的IP地址。 vagrant ssh-config >> ~/.ssh/config
vagrant ssh-config >> ~/.ssh/config
vagrant
vagrant
It worked. 有效。
I had the same issue and thanks to the solution of @Nathan I could fix the issue.我遇到了同样的问题,感谢@Nathan 的解决方案,我可以解决这个问题。 I have a different release setup.
我有不同的发布设置。 Was trying to test release a ruby project in my VM with Capistrano, but had a authentication error on user@localhost.
正在尝试使用 Capistrano 在我的 VM 中测试发布 ruby 项目,但在 user@localhost 上出现身份验证错误。 SSH user@localhost worked fine.
SSH user@localhost 工作正常。
My build setup is Oracle Virtual Box with Ubuntu 22.04 LTS installed as VM.我的构建设置是 Oracle Virtual Box,其中 Ubuntu 22.04 LTS 安装为 VM。 To connect with SSH to your VM with Capistrano you have to do the following:
要使用 Capistrano 将 SSH 连接到您的 VM,您必须执行以下操作:
Bridged Adapter
Bridged Adapter
wlp4s0
wlp4s0
Allow All
;Allow All
;inet
by running ifconfig
;ifconfig
在inet
下检查您的 ip;ssh user_for_cap@ip_address
ssh user_for_cap@ip_address
server 'ip_address', user: 'user_for_cap', roles: %w[app], port: 22
server 'ip_address', user: 'user_for_cap', roles: %w[app], port: 22
It Worked!有效!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.