gyptazy / vagrant-arm64-boxes

Collection of Vagrant Boxes for ARM64 (Apple Silicon support)
https://gyptazy.ch/blog/collection-of-vagrant-boxes-images-for-apple-silicon-based-on-arm64/
5 stars 0 forks source link

vm on oracle8.8 linux is not able to start properly due to missing passwordless sudo for vagrant user #3

Open oleksandr-shalbanov-fntext opened 11 months ago

oleksandr-shalbanov-fntext commented 11 months ago

During vagrant up getting following error:

==> database: Setting hostname...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

# Update sysconfig
if [ -f /etc/sysconfig/network ]; then
  sed -i 's/\(HOSTNAME=\).*/\1database/' /etc/sysconfig/network
fi
# Update DNS
  1 #=============================================================
find /etc/sysconfig/network-scripts -maxdepth 1 -type f -name 'ifcfg-*' | xargs -r sed -i 's/\(DHCP_HOSTNAME=\).*/\1"database"/'
# Set the hostname - use hostnamectl if available
echo 'database' > /etc/hostname

Stdout from the command:

Stderr from the command:

Vagrant file:

#=============================================================
#-----------------------Configuration-------------------------
#=============================================================

hosts = {
    'artifactory' => {
        'addr'  => '192.168.56.121', 
        'mem'   => 3072, 
        'cpus'  => 2, 
        'image' => "gyptazy/oraclelinux8.8-arm64"},
    'containerregistry' => {
        'addr'  => '192.168.56.122', 
        'mem'   => 3072, 
        'cpus'  => 2, 
        'image' => "gyptazy/oraclelinux8.8-arm64"},
    'database' => {
        'addr'  => '192.168.56.123', 
        'mem'   => 3072, 
        'cpus'  => 2, 
        'image' => "gyptazy/oraclelinux8.8-arm64"}
}
#vagrant_stuff    = '/Users/brenner/vagrant'
#source_mount     = vagrant_stuff
#dest_mount       = '/vagrant'

#=============================================================
#---------------------------Code------------------------------
#=============================================================

Vagrant.configure("2") do |config|
#config.vm.synced_folder source_mount, dest_mount 
  hosts.each { |host, params|
    config.vm.define host do |item|
    item.vm.box = params['image']
      item.vm.hostname = host
      #web.vm.box_url = "centos/7"

      item.vm.network :private_network, ip: params['addr']
      item.vm.hostname = host

      item.vm.provider :vmware_desktop do |v|
        v.vmx["memsize"] = params['mem']
        v.vmx["numvcpus"] = params['cpus']
        v.vmx["ssh_info_public"] = true
        v.vmx["ethernet0.pcislotnumber"] = "160"
        #v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
        #v.customize ["modifyvm", :id, "--name", host]
      end
    end
  }
end

Solution: after starting vm do vagrant ssh and run following:

echo "vagrant" | sudo -S chmod u+w /etc/sudoers
sudo  bash -c "echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers"
sudo chmod u-w /etc/sudoers
gyptazy commented 11 months ago

Hey @oleksandr-shalbanov-fntext,

thanks for reporting. Unfortunately, this is indeed a bug due to a missing passwordless sudo configuration with your already mentioned and provided fix. This is covered in #2 and will be fixed in upcoming releases.

Sorry for that.

Cheers, gyptazy

oleksandr-shalbanov-fntext commented 11 months ago

Also I've noticed there is problems with vmware agent: ==> database: Waiting for HGFS to become available... And it never ends.....

twhalsema commented 2 days ago

Hello, is there any update on when this will be fixed? It looks like this has been open for about a year. Is there any workaround that can be done in the Vagrantfile before it attempts to change the hostname and hits the error?

gyptazy commented 2 days ago

Hey @twhalsema,

unfortunately not before. The only way is to wait until the error occurs, afterwards you can still login to the box with vagrant ssh and use the box as usual and/or adjust the missing sudo config to avoid this behavior.