Kitchen can't see the network configuration into Vagrantfile - vagrant

I am using kitchen to test my cookbook and I made a network configuration in the Vagrantfile but the kitchen instance not see this configuration.
This is my Vagrantfile configuration.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.hostname = "demo-berkshelf"
config.vm.box = "ubuntu-12.04"
config.vm.network :private_network, ip: "33.33.33.10"
config.berkshelf.enabled = true
config.vm.provision :chef_solo do |chef|
chef.json = {
:mysql => {
:server_root_password => 'rootpass',
:server_debian_password => 'debpass',
:server_repl_password => 'replpass'
}
}
chef.run_list = [
"recipe[demo::default]"
]
end
end
And it is my .kitchen.yml configuration.
---
driver:
name: vagrant
provisioner:
name: chef_solo
platforms:
- name: ubuntu-12.04
driver_config:
box: "ubuntu-12.04"
suites:
- name: default
run_list:
- recipe[demo::default]
attributes:
When i login into kitchen show me a network configuration that i don't expect
roberto#rcisla-pc:~$ kitchen login default-ubuntu-1204
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)
* Documentation: https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Wed Jan 22 14:02:59 2014 from 10.0.2.2
vagrant#default-ubuntu-1204:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:12:96:98
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe12:9698/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:360 errors:0 dropped:0 overruns:0 frame:0
TX packets:365 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:49328 (49.3 KB) TX bytes:42004 (42.0 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Where is the 33.33.33.10 that i configured in Vagrantfile?
Thanks beforehand for any help.

Test Kitchen won't use your Vagrantfile by default; it generates its own based on the .kitchen.yml. See the README for instructions how to configure networking via it. For example:
driver:
name: vagrant
network:
- ["private_network", { ip: "192.168.33.10" }]
You can use a custom Vagrantfile template too, but normally it shouldn't be needed. See the default template for an example.
And finally, don't use 33.33.33.* addresses. That is a valid network owned by somebody. Use IPs from private networks like 10.0.0.0/8 or 192.168.0.0/16 instead. 192.168.33.* seems to be quite common with Vagrant.

Related

Virtualbox - can't use internet on terminal

I have a Linux Mint in a virtualbox VM and I'm able to use Internet through browser. However, when I've tried to use the command wget www.google.com, for example, the results is
$ wget www.google.com
--2018-12-03 16:46:10-- http://www.google.com/
Resolving www.google.com (www.google.com)... 2800:3f0:4001:810::2004,
172.217.28.4
Connecting to www.google.com
(www.google.com)|2800:3f0:4001:810::2004|:80...
I've checked the issue No internet in terminal . But, unfortunatelly appears as an specific proxy problem and that's not my case.
My VM network config
I know! Portuguese...
Basicaly, the connection type is set on "Bridge"
And "promiscuous" mode is set as 'Allow everything'.
There is no other adaptor configuration.
Result of command ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:2b:04:c7
inet addr:192.168.0.39 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: 2804:14d:c092:4057:6d41:5685:4959:c973/64 Scope:Global
inet6 addr: 2804:14d:c092:4057::1005/128 Scope:Global
inet6 addr: fe80::da8c:1d0b:592d:5c90/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:14289 errors:0 dropped:0 overruns:0 frame:0
TX packets:9307 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15589075 (15.5 MB) TX bytes:938043 (938.0 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:776 errors:0 dropped:0 overruns:0 frame:0
TX packets:776 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:66576 (66.5 KB) TX bytes:66576 (66.5 KB)
Linux Mint network config
Thanks to #darnir, I figured out how to make a 'workaround' to solve this problem! Basicaly, I had to add some 'aliases' for wget and apt-get in my .bashrc file and edit /etc/sysctl.conf
Aliases on ~/.bashrc:
# alias for wget force connection through ipv4
alias wget='wget -4 '
# alias for apt-get force connections through ipv4
apt-get='apt-get -o Acquire::ForceIPv4=true
Editing on /etc/sysctl.conf (Remember this solution is implemented over Linux Mint distro)
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
To restart systcl:
sudo sysctl -p
Or, you can use -w in sysctl command directly. But you'll lost this config as soon as you end the terminal session:
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
sysctl -w net.ipv6.conf.lo.disable_ipv6=1
WARNING this is not a good solution because is not comprehensive to all system. The problem appearently is the algorithms to resolve IPv6 is just too slow to perform properly in VMs( at least in common machines ). If someone has another idea please, post it! :D

Configure Multiple Bridge IPs in Vagrant

I have the following Vagrantfile which defines many (multi-machine) VMs:
Vagrant.configure(2) do |config|
for i in 1..3 do
config.vm.define "vm#{i}" do |c|
c.vm.box = "ubuntu/xenial64"
c.vm.network "public_network", ip: "192.168.0.#{i + 100}"
c.vm.network :forwarded_port, guest: 22, host: rand(2000...4000), id: 'ssh'
end
end
end
After performing vagrant up, each VM has the same eth1 interface:
eth1 Link encap:Ethernet HWaddr 08:00:27:43:e7:4f
inet addr:192.168.0.103 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: 2607:b400:26:0:a00:27ff:fe43:e74f/64 Scope:Global
inet6 addr: fe80::a00:27ff:fe43:e74f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:59 errors:0 dropped:0 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10065 (10.0 KB) TX bytes:3832 (3.8 KB)
I would like each VM to have a separate IP, but each one strangely adopts the IP 192.168.0.103. If I omit the ip specification to public_network, each VM's eth1 IP is different.
How can I configure multiple bridge IPs in a multi-machine Vagrantfile?
I guess its one of ruby caveat (you can read Closures and for loops in Ruby and probably other good resources on the net)
basically replace you for loop
for i in 1..3 do
with equivalent
(1..3).each do |i|

How can I find the host machine network ip address on travis?

Sorry for the naive question but I am new to using travis and read the docs thoroughly but I can't figure out what exactly I need to put in my .travis.yml or use as an IP address.
I have setup my server on local host in travis. For client testing I need the ip address of the local host to test my client app.
Any help is highly appreciated. Thanks :)
This works:
language: generic
addons:
apt:
packages:
- net-tools
script:
- /sbin/ifconfig
That installs the net-tools package, then calls the ifconfig command that package adds.
In the output from that command, you want to look at the information for the eth0 interface:
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:08
inet addr:172.17.0.8 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1245 errors:0 dropped:0 overruns:0 frame:0
TX packets:1083 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:17000256 (17.0 MB) TX bytes:122513 (122.5 KB)
But it’s better these days to instead use the ip command from the iproute2 package:
dist: trusty
language: generic
addons:
apt:
packages:
- iproute2
script:
- ip a
Sample output:
10: eth0#if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:05 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.5/16 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::42:acff:fe11:5/64 scope link
valid_lft forever preferred_lft forever

can't reach vagrant box over private network

My vagrant box stop working for unknown reason and even if a reinstall all the box trough my ansible script, it don't want to be reached by http://192.168.33.10/.
here my vagrant file :
Vagrant.configure(2) do |config|
config.vm.box = "centos67vm"
config.vm.synced_folder "../../pjt" , "/var/www/pjt", owner: "pjt", group: "pjt", mount_options: ["dmode=777,fmode=777"]
config.vm.synced_folder "../../library" , "/var/library"
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.provision :shell, path: "ansible.sh"
config.vm.provider :virtualbox do |vb|
vb.name = "dev-pjt"
end
end
when i ping the ip i got :
ping 192.168.33.10
PING 192.168.33.10 (192.168.33.10): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
^C
--- 192.168.33.10 ping statistics ---
6 packets transmitted, 0 packets received, 100.0% packet loss
the ifconfig in the box give me that :
ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:1B:2F:CC
inet adr:10.0.2.15 Bcast:10.0.2.255 Masque:255.255.255.0
adr inet6: fe80::a00:27ff:fe1b:2fcc/64 Scope:Lien
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:967 errors:0 dropped:0 overruns:0 frame:0
TX packets:635 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
RX bytes:100532 (98.1 KiB) TX bytes:85600 (83.5 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:2A:FE:79
inet adr:192.168.33.10 Bcast:192.168.33.255 Masque:255.255.255.0
adr inet6: fe80::a00:27ff:fe2a:fe79/64 Scope:Lien
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
RX bytes:0 (0.0 b) TX bytes:1974 (1.9 KiB)
lo Link encap:Boucle locale
inet adr:127.0.0.1 Masque:255.0.0.0
adr inet6: ::1/128 Scope:Hôte
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
i'm don't know where do i need to dig in to find a solution (my mac or virtualbox ?) , hope somebody can help me.
Finally resolve the problem... but don't know how... so here the steps that i did :
sudo route -n flush
rebooted the macbook
deactivated little snitch and nod32 antivirus
vagrant up
successfully ping and go to http://192.168.33.10/
vagrant halt
reactivated little snitch and nod32 antivirus
vagrant up
successfully ping and go to http://192.168.33.10/
i don't know if it's the "sudo route -n flush" or the reboot that made the connection work again.
hope it will help somebody ;)

Multiple static addresses on same interface via Vagrant

So in trying to convert manual installation instructions to Vagrant on setting up the VM, I'm stumped on how I make the /etc/network/interfaces file have the following:
auto eth1
iface eth1 inet static
address 192.168.56.101
netmask 255.255.255.0
auto eth1:1
iface eth1:1 inet static
address 192.168.56.102
netmask 255.255.255.0
auto eth1:2
iface eth1:2 inet static
address 192.168.56.103
netmask 255.255.255.0
These interfaces are all using a host-only adapter on the VM in VirtualBox.
I know I can just create three separate adapters and use the same host-only adapter doing something like this:
config.vm.network "private_network", ip: "192.168.56.101"
config.vm.network "private_network", ip: "192.168.56.102"
config.vm.network "private_network", ip: "192.168.56.103"
But that doesn't obviously match the above file. I'd rather not have some hacky solution of rewriting /etc/network/interfaces on boot-up/shutdown, but I can't seem to get Vagrant to work and can't find anything else on it beyond very simple tutorials.
I am not sure you can do that just using default network config.
I tried a few options using some parameters as
config.vm.network "private_network", ip: "192.168.50.101", :device => "eth1", :adapter => 1, :netmask => "255.255.255.0"
config.vm.network "private_network", ip: "192.168.50.102", :device => "eth1:1", :adapter => 1, :netmask => "255.255.255.0"
config.vm.network "private_network", ip: "192.168.50.103", :device => "eth1:2", :adapter => 1, :netmask => "255.255.255.0"
but this will either VM will not boot or each interface has its own interface.
Then looking at https://docs.vagrantup.com/v2/networking/public_network.html / DISABLE AUTO-CONFIGURATION, you can do the following
# manual ip
config.vm.network "public_network", auto_config: false
config.vm.provision "shell",
run: "always",
inline: "ifconfig eth1 192.168.50.101 netmask 255.255.255.0 up"
config.vm.provision "shell",
run: "always",
inline: "ifconfig eth1:1 192.168.50.102 netmask 255.255.255.0 up"
config.vm.provision "shell",
run: "always",
inline: "ifconfig eth1:2 192.168.50.103 netmask 255.255.255.0 up"
when running ifconfig -a on the VM you get
eth0 Link encap:Ethernet HWaddr 00:0c:29:e5:fe:e1
inet addr:172.16.42.238 Bcast:172.16.42.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee5:fee1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:766 errors:0 dropped:0 overruns:0 frame:0
TX packets:489 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:83256 (83.2 KB) TX bytes:69904 (69.9 KB)
eth1 Link encap:Ethernet HWaddr 00:0c:29:e5:fe:eb
inet addr:192.168.50.101 Bcast:192.168.50.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee5:feeb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:125 errors:0 dropped:20 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10180 (10.1 KB) TX bytes:1478 (1.4 KB)
eth1:1 Link encap:Ethernet HWaddr 00:0c:29:e5:fe:eb
inet addr:192.168.50.102 Bcast:192.168.50.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1:2 Link encap:Ethernet HWaddr 00:0c:29:e5:fe:eb
inet addr:192.168.50.103 Bcast:192.168.50.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Resources