public_network es shell provisioning - /tmp/vagrant-shell: Permission denied

Fórumok

Publikus IP-t (pontosabban lab IP-t) probalok definialni egy vagrant boxon.
a kovetkezo Vagrantfile-t hasznalva:

cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
config.vm.define "boxx-mybox-master-ubuntu-trusty" do |boxx|
boxx.vm.box = "boxx-mybox-master-ubuntu-trusty"
boxx.vm.hostname = "boxx-mybox-master-ubuntu-trusty"
boxx.vm.network "public_network", auto_config: false
# manual ip
boxx.vm.provision "shell",
run: "always",
inline: "ifconfig eth1 xx.xx.xx.xx netmask 255.255.255.192 up"
end
end
root@server:/data/testproject9#

root@server:/data/testproject9# vagrant up
Bringing machine 'boxx-mybox-master-ubuntu-trusty' up with 'virtualbox' provider...
==> boxx-mybox-master-ubuntu-trusty: Clearing any previously set forwarded ports...
==> boxx-mybox-master-ubuntu-trusty: Clearing any previously set network interfaces...
==> boxx-mybox-master-ubuntu-trusty: Available bridged network interfaces:
1) eth0
2) eth1
3) eth2
4) eth3
==> boxx-mybox-master-ubuntu-trusty: When choosing an interface, it is usually the one that is
==> boxx-mybox-master-ubuntu-trusty: being used to connect to the internet.
boxx-mybox-master-ubuntu-trusty: Which interface should the network bridge to? 2
==> boxx-mybox-master-ubuntu-trusty: Preparing network interfaces based on configuration...
boxx-mybox-master-ubuntu-trusty: Adapter 1: nat
boxx-mybox-master-ubuntu-trusty: Adapter 2: bridged
==> boxx-mybox-master-ubuntu-trusty: Forwarding ports...
boxx-mybox-master-ubuntu-trusty: 22 (guest) => 2222 (host) (adapter 1)
==> boxx-mybox-master-ubuntu-trusty: Booting VM...
==> boxx-mybox-master-ubuntu-trusty: Waiting for machine to boot. This may take a few minutes...
boxx-mybox-master-ubuntu-trusty: SSH address: 127.0.0.1:2222
boxx-mybox-master-ubuntu-trusty: SSH username: vagrant
boxx-mybox-master-ubuntu-trusty: SSH auth method: private key
==> boxx-mybox-master-ubuntu-trusty: Machine booted and ready!
==> boxx-mybox-master-ubuntu-trusty: Checking for guest additions in VM...
==> boxx-mybox-master-ubuntu-trusty: Setting hostname...
==> boxx-mybox-master-ubuntu-trusty: Mounting shared folders...
boxx-mybox-master-ubuntu-trusty: /vagrant => /data/testproject9
==> boxx-mybox-master-ubuntu-trusty: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> boxx-mybox-master-ubuntu-trusty: flag to force provisioning. Provisioners marked to run always will still run.
==> boxx-mybox-master-ubuntu-trusty: Running provisioner: shell...
boxx-mybox-master-ubuntu-trusty: Running: inline script
==> boxx-mybox-master-ubuntu-trusty: stdin: is not a tty
==> boxx-mybox-master-ubuntu-trusty: bash: line 2: /tmp/vagrant-shell: Permission denied
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
root@server:/data/testproject9#

a box-re feljutottam vagrant ssh-val:
cat /tmp/vagrant-shell
/sbin/ifconfig eth1 xx.xx.xx.xx netmask 255.255.255.192 up

a) ha a boxon futtatom a parancsot:
/sbin/ifconfig eth1 xx.xx.xx.xx netmask 255.255.255.192 up
SIOCSIFADDR: Operation not permitted
SIOCSIFFLAGS: Operation not permitted
SIOCSIFNETMASK: Operation not permitted
SIOCSIFFLAGS: Operation not permitted

b) sudo /sbin/ifconfig eth1 xx.xx.xx.xx netmask 255.255.255.192 up
ezzel lefut es eth1 a boxon megkapja az ip cimet.

Hogy tudom ezt a Vagrantfajlba beirni?

c) kilepve a boxbol azonban nem pingelheto ez az ip.
Megjegyzes - a host szerver ip-je es ez az xx.xx.xx.xx egy halozaton van.

Koszonom elore a segitseget.
Ardi

Hozzászólások

Itt egész jól le van írva:
-> https://www.vagrantup.com/docs/networking/public_network.html

Ha a hálózatodról pingelni szeretnéd a vagrantos gépet, akkor neked "bridge" kell a megfelelő hoston lévő hálózati interfészre (én legalábbis erre kezdeném a próbálkozást), pl. vhogy így:


config.vm.network "public_network", bridge: "eth0", ip: "xx.xx.xx.xx"

Koszi, meeg elotted sikerult ratalalni ugyanarre:

Igy nez ki a Vagrantfile-om:

cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
config.vm.define "boxx-mybox-master-ubuntu-trusty" do |boxx|
boxx.vm.box = "boxx-mybox-master-ubuntu-trusty"
boxx.vm.hostname = "boxx-mybox-master-ubuntu-trusty"
boan.vm.network :public_network, bridge: 'eth1', ip: 'xx.xx.xx.xx', netmask: '255.255.255.192'
end
end

A boxon levo eth1 meg is kapja az xx.xx.xx.xx ip cimet, azonban nem tudom
pingelni sem a host ip cimet (ugyanazon a halozaton van xx.xx.xx.aa ip cimmel), sem pedig forditva.

Ez hogy oldhato meg?
Ardi

Rajottem, hogy vmit osszekutyultam.

Ha boan.vm.network :public_network, bridge: 'eth0', ip: 'xx.xx.xx.xx', netmask: '255.255.255.192'-t hasznalok, nem kapja meg a box eth1 interfesze az xx.xx.xx.xx cimet.
Sajnos, hibat sem kapok.

Szerintem vhol ott lehet a hiba, hogy nem teljesen koser box-ot hoztam letre.

Ha ugyanis a boxon kiadom mint vagrant user:
sudo /sbin/ifconfig eth1 xx.xx.xx.xx netmask 255.255.255.192 up

akkor eth1 interfesz a boxon megkapja a xx.xx.xx.xx cimet.
De a ping akkor sem mukodik.

Note: eth0 a host szerver interfesze, amin keresztul kene a kulso halozattal kommunikalnia a boxnak?

Ardi