Ruby 如何使用vagrant在GCE实例上允许HTTP流量和端口27017?
我使用Vagrantfile创建了一个MongoDB GCE实例。然后启用“允许HTTP通信”,并使用控制台添加协议:端口tcp:27017。一切正常,但我想避免使用控制台。 有人能帮我启用“允许HTTP通信”并用Vagrantfile添加“端口tcp:27017”吗 这是我的流浪汉档案的一部分:Ruby 如何使用vagrant在GCE实例上允许HTTP流量和端口27017?,ruby,vagrant,google-compute-engine,Ruby,Vagrant,Google Compute Engine,我使用Vagrantfile创建了一个MongoDB GCE实例。然后启用“允许HTTP通信”,并使用控制台添加协议:端口tcp:27017。一切正常,但我想避免使用控制台。 有人能帮我启用“允许HTTP通信”并用Vagrantfile添加“端口tcp:27017”吗 这是我的流浪汉档案的一部分: Vagrant.configure(“2”)do | config| config.vm.box=“谷歌/gce” config.ssh.forward\u agent=true config.vm.
Vagrant.configure(“2”)do | config|
config.vm.box=“谷歌/gce”
config.ssh.forward\u agent=true
config.vm.provider:google do | google,覆盖|
google.google\u project\u id=“projectxx”
google.google\u client\u email=“xx-compute@developer.gserviceaccount.com"
google.google\u json\u key\u location=“~/gcp\u service\u keys/xx.json”
google.name=“namex”
google.zone=“us-central1-c”
google.image_family='ubuntu-1804-lts'
override.ssh.username=“我”
override.ssh.private\u key\u path=“~/.ssh/gce”
结束
config.vm.provision:shell,路径:“install.sh”
结束
你检查过流浪汉了吗
应该是这样的:
Vagrant.configure("2") do |config|
config.vm.box = "google/gce"
config.vm.network "forwarded_port", guest: 80, host: 27017
#... rest of your config
end
添加网络标记可以完成这项工作
google.tags=['http-server']
您必须添加防火墙规则并在其上添加“目标标记”,例如test-1,然后在您的vagrant文件上,您必须使用此行google.tags=['test-1']
Vagrant.configure(“2”)do | config|
config.vm.box=“谷歌/gce”
config.ssh.forward\u agent=true
config.vm.provider:google do | google,覆盖|
google.google\u project\u id=“projectxx”
google.google\u client\u email=“xx-compute@developer.gserviceaccount.com"
google.google\u json\u key\u location=“~/gcp\u service\u keys/xx.json”
google.name=“namex”
google.zone=“us-central1-c”
google.image_family='ubuntu-1804-lts'
google.tags=['test-1']是的,我试过了。我认为它不适用于GCP。它给我:==>默认值:警告!Google提供程序不支持任何Vagrant==>默认值:高级网络配置(
config.vm.network)。它们==>默认值:将被静默忽略。
config.ssh.forward_agent = true
config.vm.provider :google do |google, override|
google.google_project_id = "projectxx"
google.google_client_email = "xx-compute@developer.gserviceaccount.com"
google.google_json_key_location = "~/gcp_service_keys/xx.json"
google.name = "namex"
google.zone = "us-central1-c"
google.image_family = 'ubuntu-1804-lts'
google.tags = ['test-1'] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
override.ssh.username = "me"
override.ssh.private_key_path = "~/.ssh/gce"
end
config.vm.provision :shell, path: "install.sh"