Skip to content

Commit baace92

Browse files
committed
fix: ansible vagrant ssh connection error
1 parent da998ff commit baace92

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SSH Connection Error when using Vagrant and Ansible
2+
3+
I got the following error when using Vagrant and the Ansible provisioner:
4+
```bash
5+
TASK [Install packages] ********************************************************
6+
fatal: [default]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 192.168.124.116 closed.\r\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 137}
7+
```
8+
9+
This error occured every time I tried to provision the VM with Ansible.
10+
11+
With using `ansible.verbose = "vvvvv"` in the Vagrantfile I got the following output:
12+
13+
```bash
14+
--- snip ---
15+
mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 137\r\nShared connection to 192.168.124.116 closed.\r\n",
16+
--- snip ---
17+
```
18+
19+
Error code 137 is issued when a process is terminated externally because of its memory consumption.
20+
21+
When checking the kernel logs with `journalctl -t oom_reaper` I found the following lines:
22+
23+
```bash
24+
vagrant ssh
25+
dmesg | grep oom
26+
[ 1158.525674] Out of memory: Killed process 2428 (dnf) total-vm:479860kB, anon-rss:352668kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:836kB oom_score_adj:0
27+
[ 6304.776507] python3 invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=0
28+
[ 6304.776529] oom_kill_process.cold+0xb/0x10
29+
[ 6304.776637] [ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name
30+
[ 6304.776674] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/session-5.scope,task=python3,pid=2879,uid=0
31+
[ 6304.776682] Out of memory: Killed process 2879 (python3) total-vm:401128kB, anon-rss:341880kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:816kB oom_score_adj:
32+
```
33+
34+
It clearly shows that the process `dnf` was killed because of the memory consumption.
35+
36+
The default Vagrant VM has 512 MB RAM. It seems that this is not enough for the Ansible provisioning.
37+
38+
I increased the RAM to 2048 MB and the provisioning worked without any problems.
39+
40+
```ruby
41+
config.vm.provider "libvirt" do |libv|
42+
libv.memory = "4096"
43+
end
44+
```

0 commit comments

Comments
 (0)