Table of Content

vagrant stuck at "Setting hostname" for private network setup

==> ctosbox2: Setting hostname...

debug log

from debug log, it used hostnamectl to change hostname, then will restart network service,

DEBUG ssh: stderr: 41e57d38-b4f7-4e46-9c38-13873d338b86-vagrant-sshDEBUG ssh: stderr: cat: /etc/photon-release: No such file or directoryDEBUG ssh: Exit status: 1
DEBUG guest: Trying: redhat
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: cat /etc/redhat-release (sudo=false)
DEBUG ssh: stderr: 41e57d38-b4f7-4e46-9c38-13873d338b86-vagrant-sshDEBUG ssh: Exit status: 0 
INFO guest: Detected: redhat!
DEBUG guest: Searching for cap: change_host_name
DEBUG guest: Checking in: redhat
DEBUG guest: Found cap: change_host_name in redhat
INFO guest: Execute capability: change_host_name [#<:machine: ctosbox2>, "ctosbox2"] (redhat)
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: hostname -f | grep '^ctosbox2$' (sudo=false)
DEBUG ssh: stderr: 41e57d38-b4f7-4e46-9c38-13873d338b86-vagrant-sshDEBUG ssh:
Exit status: 1 
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: # Update sysconfig
sed -i 's/\(HOSTNAME=\).*/\1ctosbox2/' /etc/sysconfig/network

# Update DNS
sed -i 's/\(DHCP_HOSTNAME=\).*/\1"ctosbox2"/' /etc/sysconfig/network-scripts/ifcfg-*

# Set the hostname - use hostnamectl if available

echo 'ctosbox2' > /etc/hostname

if command -v hostnamectl; then
  hostnamectl set-hostname --static 'ctosbox2'
  hostnamectl set-hostname --transient 'ctosbox2'
else
  hostname -F /etc/hostname
fi

# Prepend ourselves to /etc/hosts

grep -w 'ctosbox2' /etc/hosts || {
  sed -i'' '1i 127.0.0.1\tctosbox2\tctosbox2' /etc/hosts
}
# Restart network

service network restart

 (sudo=true)

DEBUG ssh: stderr: 41e57d38-b4f7-4e46-9c38-13873d338b86-vagrant-ssh
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...         

it hanging there forever.

deep look inside vm

however when login to vm, found the hostonly interface enp0s8 show up in "ip addr" but ifcfg-enp0s8 not created and network service not restarted,

[vagrant@ctosbox2 ~]$ ip addr
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3:  mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 08:00:27:ef:0c:e6 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a00:27ff:feef:ce6/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s8:  mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 08:00:27:8c:e9:49 brd ff:ff:ff:ff:ff:ff
4: ovs-system:  mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether da:b4:e4:d4:05:a2 brd ff:ff:ff:ff:ff:ff
5: br-tun:  mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether ae:7a:85:a5:fc:45 brd ff:ff:ff:ff:ff:ff
6: br-int:  mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 82:9b:a5:e1:ee:41 brd ff:ff:ff:ff:ff:ff
8: br-ex:  mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether 08:00:27:ef:0c:e6 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic br-ex
       valid_lft 85383sec preferred_lft 85383sec
    inet6 fe80::a00:27ff:feef:ce6/64 scope link
       valid_lft forever preferred_lft forever

[vagrant@ctosbox2 ~]$ sudo systemctl status network
? network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
   Active: active (running) since Tue 2018-02-27 18:10:33 UTC; 17min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 16411 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
  Process: 16657 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/network.service
           +-16945 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--br-ex.lease -pf /var/run/dhclient-br-ex.pid -H ctosbox2 br-ex

Feb 27 18:10:24 ctosbox2 network[16657]: Bringing up interface br-ex:  [  OK  ]
Feb 27 18:10:25 ctosbox2 ovs-vsctl[16864]: ovs|00001|vsctl|INFO|Called as ovs-vsctl -t 10 -- --if-exists del-port br-ex enp0s3 -... enp0s3
Feb 27 18:10:25 ctosbox2 ovs-vsctl[16879]: ovs|00001|vsctl|INFO|Called as ovs-vsctl -t 10 -- --may-exist add-br br-ex -- set bri...ndalone
Feb 27 18:10:25 ctosbox2 network[16657]: Bringing up interface enp0s3:
Feb 27 18:10:26 ctosbox2 dhclient[16891]: DHCPREQUEST on br-ex to 255.255.255.255 port 67 (xid=0x40b6f761)
Feb 27 18:10:30 ctosbox2 dhclient[16891]: DHCPREQUEST on br-ex to 255.255.255.255 port 67 (xid=0x40b6f761)
Feb 27 18:10:30 ctosbox2 dhclient[16891]: DHCPACK from 10.0.2.2 (xid=0x40b6f761)
Feb 27 18:10:32 ctosbox2 network[16657]: Determining IP information for br-ex... done.
Feb 27 18:10:33 ctosbox2 network[16657]: [  OK  ]
Feb 27 18:10:33 ctosbox2 systemd[1]: Started LSB: Bring up/down networking.
Hint: Some lines were ellipsized, use -l to show in full.

[vagrant@ctosbox2 ~]$ date
Tue Feb 27 18:28:07 UTC 2018

next action plan

if look around Internet, this issue happened for long time and still no solid solution yet.

My feeling is kind of handling issue of hostname/new interface/network service.