I have figured out how to use Sublime SFTP with Vagrant. But I constantly am switching between multiple Vagrant VMs and running multiple VMs at once. In order to connect Sublime SFTP to the VM, you have to set the host:
"host": "127.0.0.1",
"user": "vagrant",
//"password": "",
"port": "2222",
"ssh_key_file": "/home/jeremy/.vagrant/machines/inspire/virtualbox/private_key",
The only problem is the "port": "222" field will change depending on when I start up which VMs and how many I am running. So it makes it impossible to use sublime with these VMs with having to reconfigure the sftp_servers file first. Is there any way to permanently assign the port to the VM or a better way to accomplish what I am trying to do?
in your Vagrantfile you can define the ssh port with property config.ssh.port
Related
I have one machine (A) from which I run Ansible playbooks on a variety of hosts. Vagrant is not installed here.
I have another machine (B) with double the RAM that hosts my Vagrant boxes. Ansible is not installed here.
I want to use Ansible to act on Vagrant boxes the same way I do all other hosts; that is, running ansible-playbook on machineA while targeting a virtualized Vagrant box on machineB. SSH keys are already set up between the two.
This seems like a simple use case but I can't find it clearly explained anywhere given the encouraged use of Vagrant's built-in Ansible provisioner. Is it possible?
Perhaps some combination of SSH tunnels and port forwarding trickery?
Turns out this was surprisingly simple. Vagrant in fact does not need to know about Ansible at all.
Ansible inventory on machineA:
default ansible_host=machineB ansible_port=2222
Vagrantfile on machineB:
Vagrant.configure("2") do |config|
...
config.vm.network "forwarded_port", id: "ssh", guest: 22, host: 2222
...
end
The id: "ssh" is the important bit, as this overrides the default SSH behavior of restricting SSH to the guest from localhost only.
$ ansible --private-key=~/.ssh/vagrant-default -u vagrant -m ping default
default | SUCCESS => {
"changed": false,
"ping": "pong"
j }
(Note that the Vagrant private key must be copied over to the Ansible host and specified at the command line).
I have ec2 instance running and which is linked with elastic ip.
when I ping it from local machine then It shows request time out because of which I am not able connect to it via putty and win scp.
I am facing this issue from last 2days.
It was working well for last 2 months.
Please help.
My instance is runig and healthy.
If you want to ping an EC2 instance from your local machine you need to allow inbound Internet Control Message Protocol (ICMP) traffic. Please check your Security Groups to make sure this is allowed. Remember that all inbound traffic is disable by default. You may need to establish a rule similar to this one (JSON format):
"AllowIngressICMP": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": <Your Security Group here>,
"IpProtocol": "icmp",
"FromPort": "-I",
"ToPort": "-I",
"CidrIp": "0.0.0.0/0"
** The -I means "every port"
I have two different Docker containers under the same host stack.
Currently I'm on OSX and using Sublime Text 3 with the SFTP plugin.
For each different dev environment (Docker container) I have a different sftp-config.jsonfile and I am using different SSH key files.
Here are my host entries for both files:
first host:
"host": "example-dev.xxx.de",
"user": "userxxx",
"remote_path": "/home/xxx/www_trunk",
"ssh_key_file": "~/work/Misc/pass/private1.pem"
second host:
"host": "example2-dev.xxx.de",
"user": "userxxx",
"remote_path": "/home/xxx/www_trunk",
"ssh_key_file": "~/work/Misc/pass/private2.pem"
But when I try to connect to the second host, I always end up on the fist one.
I had the same problem with the OSX terminal before, until I added "IdentitiesOnly YES" to the SSH config file, then I connected to the correct dev environment.
Is there any setting similar to "IdentitiesOnly YES" that I need to add to the sftp-config.json files, so that my sublime text also connects to the correct dev environment?
I have a VMWARE image running CentOS.I want to create a vagrant box from it with packer. I am new to Vagrant and can anyone suggest the steps?
Using Packer to apply additional provisioning steps to an existing VM is supported by Packer via the vmware-vmx builder
This VMware Packer builder is able to create VMware virtual machines
from an existing VMware virtual machine (a VMX file). It currently
supports building virtual machines on hosts running VMware Fusion
Professional for OS X, VMware Workstation for Linux and Windows, and
VMware Player on Linux.
In your situation where you have an existing CentOS VMX and want to turn it into a Vagrant box you would create packer.json configuration file like so:
{
"builders": [{
"type": "vmware-vmx",
"source_path": "/path/to/a/vm.vmx",
"ssh_username": "root",
"ssh_password": "root",
"ssh_wait_timeout": "30s",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
}],
"provisioners": [{
"type": "shell",
"inline": ["echo 'my additional provisioning steps'"]
}],
"post-processors": [{
"type": "vagrant",
"keep_input_artifact": true,
"output": "mycentos.box"
}]
}
Packer would clone the source VMX, boot the box, apply any provisioning steps you had, shut down the box, and then output a new Vagrant ".box" file.
It sounds like you won't be able to.
Packer assumes a base box (for vagrant) and ends at a new box. You can't go from a running VM to a box via Packer.
If you started the CentOS VM using vagrant, you can do vagrant export
If you have a running VM you made manually, your best bet is to start over using a Vagrant box. If you want to continue with this route: http://docs.vagrantup.com/v2/vmware/boxes.html
I'm very new to the land of virtual machines and vagrant, so please forgive my general ignorance about all of this.
The other day, I downloaded DSTK vagrant box and followed the instructions on the documentation page to get it set up so I could run many, many thousands of requests through it on my local machine rather than bombarding the public server (and also, it should be faster; and also, DSTK is down at the moment so it was the only option).
After many hours of waiting for vagrant to add and init the box on my tired old hard drive, it worked! I used curl to make a few requests, got the expected responses, and patted myself on the back. I closed my terminal and put away my computer and drank beer.
... And then, the next morning, this happened:
$ curl -d "Joe Biden" "localhost:8080/text2people"
curl: (7) Failed to connect to localhost port 8080: Connection refused
I can't work out why. I tried vagrant suspend; vagrant up. Same thing. vagrant halt; vagrant up. Same thing. When I've halted vagrant and run 'vagrant up' again, this appears in the readout, which makes me think it ought to be working.
==> default: Forwarding ports...
default: 80 => 8080 (adapter 1)
default: 22 => 2222 (adapter 1)
I can run vagrant ssh and get in, look around, and I see that all the files are in the right right place.
I suppose I could remove the box and re-add it, but it really did take hours to add and init and now I'm running up against a deadline where I need to it work, and I imagine there is a very simple thing of which I am not aware that is causing my problem. Google has thus far been unhelpful, probably because of how unfamiliar I am with vagrant, generally.
I have just encountered the same problem, in my case the solution was to ensure that the following line is not commented on the Vagrantfile:
config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
So it's not a problem with vagrant or virtualbox at all.
It turns out I just didn't stop to think about whether curl could be the culprit, and when I got around to this again, fixing it was as simple as curl "127.0.0.1:8080/...". Apparently curl (or at least the native Mac OSX implementation) doesn't like localhost.
I did try to Google about it for a few minutes, though, and I came across my own un-answered question, which was sort of a bummer—so in case anybody else ever has this problem, here's your fix.
curl "localhost:8080/text2people" -d "Joe Biden"
curl: (7) Failed to connect to localhost port 8080: Connection refused
curl "127.0.0.1:8080/text2people" -d "Joe Biden"
[
{
"title": "",
"gender": "m",
"start_index": 0,
"first_name": "Joe",
"end_index": 9,
"surnames": "Biden",
"ethnicity": {
"percentage_american_indian_or_alaska_native": 0.0,
"rank": 114852,
"percentage_two_or_more": 0.0,
"percentage_of_total": 5.0e-05,
"percentage_hispanic": 0.0,
"percentage_white": 96.45,
"percentage_black": 0.0,
"percentage_asian_or_pacific_islander": 0.0
},
"matched_string": "Joe Biden"
}
]