hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.28k stars 4.44k forks source link

centos 8 failed to restart network service #11911

Closed karasjoh000 closed 4 years ago

karasjoh000 commented 4 years ago

Vagrant version

Vagrant 2.0.3

Host operating system

Ubuntu 18.04.4 LTS

Guest operating system

CentOS 8

Vagrantfile

# 8 core cpu 
# ------------
# 4 workers 3 masters 1 cpu each. Total of 7 cores. 
$cpus = 1 
$k8m = 3  # 3 masters 
$k8w = 4  # 4 workers 

# 32GB ram 
# 4GB * 7 nodes = 28GB 
$ram = 4000

# 120GB disk available 
$disk_size = "10G"

Vagrant.configure("2") do |config| 

    config.vm.box = "centos/8"

    config.vm.provider :libvirt do |libvirt| 
        libvirt.nested = true
        libvirt.cpu_mode = "host-model"
    end

    # plugin conflict
    if Vagrant.has_plugin?("vagrant-vbguest") then
        config.vbguest.auto_update = false
    end

    unless Vagrant.has_plugin?("vagrant-disksize") 
        system "vagrant plugin install vagrant-disksize"
    end 
    config.disksize.size = $disk_size

    tasks = 0
    (1..$k8m).each do |m| 
        config.vm.define "master-#{m}" do |master|
            master.vm.hostname = "master-#{m}"
            master.vm.network "private_network", ip: "10.0.0.#{20 + m}"
        end
        if m == $k8m 
            (1..$k8w).each do |w| 
                config.vm.define "worker-#{w}" do |worker|
                    worker.vm.hostname = "worker-#{w}"
                    worker.vm.network "private_network", ip: "10.0.0.#{20 + $k8m + w}"
                end
            end 
        end
    end 
end

Debug output

https://gist.github.com/6a70a091674c6328ad95e05037054482.git

Expected behavior

Should provision centos 8 machines

Actual behavior

Error:

==> master-2: An error occurred. The error will be shown after all tasks complete.
An error occurred while executing multiple actions in parallel.
Any errors that occurred are shown below.

An error occurred while executing the action on the 'master-1'
machine. Please handle this error then try again:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

# Update sysconfig
sed -i 's/\(HOSTNAME=\).*/\1master-1/' /etc/sysconfig/network

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

# Set the hostname - use hostnamectl if available
echo 'master-1' > /etc/hostname
if command -v hostnamectl; then
  hostnamectl set-hostname --static 'master-1'
  hostnamectl set-hostname --transient 'master-1'
else
  hostname -F /etc/hostname
fi

# Prepend ourselves to /etc/hosts
grep -w 'master-1' /etc/hosts || {
  sed -i'' '1i 127.0.0.1\tmaster-1\tmaster-1' /etc/hosts
}

# Restart network
service network restart

Stdout from the command:

/bin/hostnamectl

Stderr from the command:

Redirecting to /bin/systemctl restart network.service
Failed to restart network.service: Unit network.service not found.

Steps to reproduce

  1. vagrant up --provider=libvirt
soapy1 commented 4 years ago

Hey there, thanks for submitting an issue. It looks like the version of Vagrant you are using is pretty old. I am unable to reproduce this issue with the current release of Vagrant (2.2.10). Does upgrading resolve the issue for you?

karasjoh000 commented 4 years ago

updated the version, works fine now

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.