GovReady / testmachines

pre-configured virtual machines for testing GovReady
7 stars 0 forks source link

Virtualbox guest additions not available on RHEL64 #3

Closed gregelin closed 10 years ago

gregelin commented 10 years ago

Virtualbox guest additions not available on RHEL 6.4 vagrant box. Problem most likely caused in vbkick build process because of Default requiretty value in /etc/sudoers file.

Here is the error produced during vagrant up:

==> rhel64: Checking for guest additions in VM...
    rhel64: No guest additions were detected on the base box for this VM! Guest
    rhel64: additions are required for forwarded ports, shared folders, host only
    rhel64: networking, and more. If SSH fails on this machine, please install
    rhel64: the guest additions and repackage the box to continue.
    rhel64:
    rhel64: This is not an error message; everything may continue to work properly,
    rhel64: in which case you may ignore this message.
==> rhel64: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

touch /etc/sysconfig/network-scripts/ifcfg-eth1

Stdout from the command:

Stderr from the command:

sudo: sorry, you must have a tty to run sudo

The correction appears to be to adjust the vbkick file such that the Default requiretty is commented out in /etc/sudoers file.

The adjustment to the /etc/sudoers file can be made during the vbkick build process by making sure postinstall/sudo.sh file is executed and contains the below sed command to comment out the Default requiretty line:

#!/bin/bash
set -e -E -u -o pipefail; shopt -s failglob;

# Allow sudo commands without a tty
sed -i "s/\(^Defaults[ ]\+requiretty\)/#\1/" /etc/sudoers
gregelin commented 10 years ago

Attempted to create a new RHEL64 box with adjusting vbkick files. Received same error.

==> rhel64db: Machine booted and ready!
==> rhel64db: Checking for guest additions in VM...
    rhel64db: No guest additions were detected on the base box for this VM! Guest
    rhel64db: additions are required for forwarded ports, shared folders, host only
    rhel64db: networking, and more. If SSH fails on this machine, please install
    rhel64db: the guest additions and repackage the box to continue.
    rhel64db:
    rhel64db: This is not an error message; everything may continue to work properly,
    rhel64db: in which case you may ignore this message.
==> rhel64db: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

touch /etc/sysconfig/network-scripts/ifcfg-eth1

Stdout from the command:

Stderr from the command:

sudo: sorry, you must have a tty to run sudo
gregelin commented 10 years ago

Still failing. Here is latest vbmachine.cfg

vbkick version is: 0.7.0

. ./common.cfg

os_type_id="RedHat_64"

# Hard code boot file to location on my computer. Update for different computers.
boot_file="/codedata/virtualmachines/rhel-server-6.4-x86_64-dvd.iso"

# follow: https://rhn.redhat.com/rhn/software/channel/downloads/Download.do?cid=10486
boot_file_src="https://content-web.rhn.redhat.com/rhn/isos/rhel-6.4/md5sum/467b53791903f9a0c477cbb1b24ffd1f/rhel-server-6.4-x86_64-dvd.iso?__gda__=1401798210_26374cc2c8a6770336cb4cc15ce56b18&ext=.iso"
boot_file_src_checksum="467b53791903f9a0c477cbb1b24ffd1f" #md5
boot_cmd_sequence=(
    "<Tab> text ks=http://%IP%:%PORT%/kickstart/rhel-6.4-x86_64-X-db.cfg<Enter>"
)
postinstall_launch=(
    #"cd postinstall && sudo bash adm_postinstall.sh adm_context_govready-rhel64.txt"
    "sudo bash postinstall/base.sh"
    "sudo bash postinstall/sudo.sh"
    "sudo bash postinstall/virtualbox.sh"
    "sudo bash postinstall/cleanup.sh"
    "sudo bash postinstall/zerodisk.sh"
)
postinstall_transport=("postinstall")
validate_launch=("cd validate && bash adm_features.sh adm_context_govready-rhel64.txt")
validate_transport=("validate")
________________________________________________________________________________
| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4 @ mbair (greg)
| => vbkick build rhel64db2
[INFO] Loading "vbmachine.cfg" definition...
Serving HTTP on 0.0.0.0 port 7001 ...
[INFO] webserver has been started (pid 24415)
Virtual machine 'rhel64db2' is created and registered.
UUID: ac9be0f5-507a-4205-859c-2ab8da4fe80d
Settings file: '/Users/greg/VirtualBox VMs/rhel64db2/rhel64db2.vbox'
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: 33b394e9-22b6-475b-8a6f-b3d5d9a2abf8
[INFO] VBoxManage sharedfolder add  "rhel64db2" --name "vbkick" --hostpath "/codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4" --automount
Waiting for VM "rhel64db2" to power on...
VM "rhel64db2" has been successfully started.
[INFO] Sending keyboard scancodes:
[INFO] <Tab> text ks=http://10.0.2.2:7001/kickstart/rhel-6.4-x86_64-X-db.cfg<Enter>

[INFO] Waiting for ssh login with user vagrant to 127.0.0.1:2001 to work, kickstart_timeout=7200 sec
..............127.0.0.1 - - [31/Aug/2014 07:22:43] "GET /kickstart/rhel-6.4-x86_64-X-db.cfg HTTP/1.1" 200 -
......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

[INFO] Stopping webserver (pid 24415)
[INFO] webserver was stopped
________________________________________________________________________________
| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4 @ mbair (greg)
| => vbkick ssh rhel64db2
[INFO] Loading "vbmachine.cfg" definition...
Last login: Sun Aug 31 07:43:32 2014 from 10.0.2.2
[vagrant@vagrant ~]$ sudo cat /etc/sudoers | grep requiretty
Defaults    requiretty
# changed in order to be able to use sudo without a tty. See requiretty above.
[vagrant@vagrant ~]$ exit
logout
________________________________________________________________________________
| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4 @ mbair (greg)
| => vbkick validate rhel64db2
[INFO] Loading "vbmachine.cfg" definition...
[INFO] Scp: validate
[INFO] Exec: cd validate && bash adm_features.sh adm_context_govready-rhel64.txt
sudo requiretty: FAIL
VBoxControl: FAIL
[INFO] Clean transported: validate
gregelin commented 10 years ago

@wilas - I am having some problems with v 0.7.0 and execution of the postinstall scripts. I do not think postinstall steps are executing.

gregelin commented 10 years ago

Problem found again on a different CentOS vm.

vbmachine.cfg

cpu_count=1
memory_size=512
disk_size=(10140)
disk_format="vdi"
video_memory_size=10
hostiocache="on"
vm_options=("ioapic:on")
nic_type="virtio"
guest_additions_attach=1
boot_file_src_path="iso"
boot_file_checksum_type="md5"
boot_wait=10
kickstart_port=${KS_PORT:-7001}
kickstart_timeout=7200
ssh_host_port=${SSH_PORT:-2001}
ssh_user="vagrant"
ssh_priv_key="vagrant_key"
ssh_priv_key_src="https://raw.github.com/mitchellh/vagrant/master/keys/vagrant"
clean_transported=1
shutdown_cmd="sudo /sbin/halt -h -p"
shutdown_timeout=20
update_launch=(
    "sudo bash virtualbox.sh"
    "sudo bash -c 'yum -y update && yum -y clean all'"
)
update_transport=("postinstall/virtualbox.sh")
play_launch=("${SSH_CMD:-}")
play_transport=("")
files_to_autoupdate_vbox_version=(
    "postinstall/adm_envrc"
    "validate/adm_envrc"
)

os_type_id="RedHat_64"
boot_file="%SRCPATH%/CentOS-6.5-x86_64-netinstall.iso"
boot_file_src="http://mirror.itc.virginia.edu/CentOS/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso"
boot_file_src_checksum="0d9dc37b5dd4befa1c440d2174e88a87"
boot_cmd_sequence=(
    "<Tab> text ks=http://%IP%:%PORT%/kickstart/centos-6.5-x86_64-noX.cfg<Enter>"
)
postinstall_launch=(
    "cd postinstall && sudo bash adm_postinstall.sh"
)
postinstall_transport=("postinstall")
validate_launch=("cd validate && bash adm_features.sh")
validate_transport=("validate")

Building and Validating. Validation still fails.


| /codedata/code/GovReady Library/current/testmachines-govreadystats/vbkick-templates/Centos6.5 @ new-host-5 (greg)
| => vbkick build centos65stats
[INFO] Loading "vbmachine.cfg" definition...
Serving HTTP on 0.0.0.0 port 7001 ...
[INFO] webserver has been started (pid 27925)
Virtual machine 'centos65stats' is created and registered.
UUID: 02524450-f07a-4ddb-a4ed-5bd27e029657
Settings file: '/Users/greg/VirtualBox VMs/centos65stats/centos65stats.vbox'
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: e74fe836-47a1-41c6-8de6-a8a287cb5a44
[INFO] VBoxManage sharedfolder add  "centos65stats" --name "vbkick" --hostpath "/codedata/code/GovReady Library/current/testmachines-govreadystats/vbkick-templates/Centos6.5" --automount
Waiting for VM "centos65stats" to power on...
VM "centos65stats" has been successfully started.
[INFO] Sending keyboard scancodes:
[INFO] <Tab> text ks=http://10.0.2.2:7001/kickstart/centos-6.5-x86_64-noX.cfg<Enter>

[INFO] Waiting for ssh login with user vagrant to 127.0.0.1:2001 to work, kickstart_timeout=7200 sec
................127.0.0.1 - - [31/Aug/2014 08:03:48] "GET /kickstart/centos-6.5-x86_64-noX.cfg HTTP/1.1" 200 -
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

[INFO] Stopping webserver (pid 27925)
[INFO] webserver was stopped
________________________________________________________________________________
| /codedata/code/GovReady Library/current/testmachines-govreadystats/vbkick-templates/Centos6.5 @ new-host-5 (greg)
| => vbkick ssh centos65stats
[INFO] Loading "vbmachine.cfg" definition...
Last login: Sun Aug 31 08:57:07 2014 from 10.0.2.2
[vagrant@vagrant ~]$ sudo cat /etc/sudoers | grep require tty
grep: tty: No such file or directory
[vagrant@vagrant ~]$ sudo cat /etc/sudoers | grep requiretty
Defaults    requiretty
# changed in order to be able to use sudo without a tty. See requiretty above.
[vagrant@vagrant ~]$ exit
logout
________________________________________________________________________________
| /codedata/code/GovReady Library/current/testmachines-govreadystats/vbkick-templates/Centos6.5 @ new-host-5 (greg)
| => vbkick validate centos65stats
[INFO] Loading "vbmachine.cfg" definition...
[INFO] Scp: validate
[INFO] Exec: cd validate && bash adm_features.sh
VBoxControl: FAIL
sudo requiretty: FAIL
vagrant user: OK
ruby: FAIL
ansible: FAIL
puppet: FAIL
chef-client: FAIL
cfengine: FAIL
[INFO] Clean transported: validate
gregelin commented 10 years ago

Removed all processes that might require RedHat subscription, and item still failing.

vbmachine.cfg:

. ./common.cfg

os_type_id="RedHat_64"

# Hard code boot file to location on my computer. Update for different computers.
boot_file="/codedata/virtualmachines/rhel-server-6.4-x86_64-dvd.iso"

# follow: https://rhn.redhat.com/rhn/software/channel/downloads/Download.do?cid=10486
boot_file_src="https://content-web.rhn.redhat.com/rhn/isos/rhel-6.4/md5sum/467b53791903f9a0c477cbb1b24ffd1f/rhel-server-6.4-x86_64-dvd.iso?__gda__=1401798210_26374cc2c8a6770336cb4cc15ce56b18&ext=.iso"
boot_file_src_checksum="467b53791903f9a0c477cbb1b24ffd1f" #md5
boot_cmd_sequence=(
    "<Tab> text ks=http://%IP%:%PORT%/kickstart/rhel-6.4-x86_64-X-db.cfg<Enter>"
)
postinstall_launch=(
    "sudo bash postinstall/sudo.sh"
    "sudo bash postinstall/virtualbox.sh"
    "sudo bash postinstall/cleanup.sh"
    "sudo bash postinstall/zerodisk.sh"
    #"cd postinstall && sudo bash adm_postinstall.sh adm_context_govready-rhel64.txt"
    #"sudo bash postinstall/base.sh"
)
postinstall_transport=("postinstall")
validate_launch=("cd validate && bash adm_features.sh adm_context_govready-rhel64.txt")
validate_transport=("validate")
| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4 @ mbair (greg)
| => vbkick build rhel64db3
[INFO] Loading "vbmachine.cfg" definition...
Serving HTTP on 0.0.0.0 port 7001 ...
[INFO] webserver has been started (pid 35877)
Virtual machine 'rhel64db3' is created and registered.
UUID: 9dec8371-b0e5-4d8a-9b40-d71a609be397
Settings file: '/Users/greg/VirtualBox VMs/rhel64db3/rhel64db3.vbox'
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: 295fbd60-5f9e-42cb-a58d-b384e7606a3a
[INFO] VBoxManage sharedfolder add  "rhel64db3" --name "vbkick" --hostpath "/codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4" --automount
Waiting for VM "rhel64db3" to power on...
VM "rhel64db3" has been successfully started.
[INFO] Sending keyboard scancodes:
[INFO] <Tab> text ks=http://10.0.2.2:7001/kickstart/rhel-6.4-x86_64-X-db.cfg<Enter>

[INFO] Waiting for ssh login with user vagrant to 127.0.0.1:2001 to work, kickstart_timeout=7200 sec
...............127.0.0.1 - - [31/Aug/2014 10:03:04] "GET /kickstart/rhel-6.4-x86_64-X-db.cfg HTTP/1.1" 200 -
.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

[INFO] Stopping webserver (pid 35877)
[INFO] webserver was stopped
________________________________________________________________________________
| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4 @ mbair (greg)
| => vbkick validate rhel64db3
[INFO] Loading "vbmachine.cfg" definition...
[INFO] Scp: validate
[INFO] Exec: cd validate && bash adm_features.sh adm_context_govready-rhel64.txt
sudo requiretty: FAIL
VBoxControl: FAIL
[INFO] Clean transported: validate
wilas commented 10 years ago

To execute commands specify in postinstall_launch you have to run vbkick postinstall VM_NAME. Postinstall and build are 2 separate processes (if you are using "lazy" postinstall method).

More details about postinstall methods you can find here: https://github.com/wilas/vbkick/blob/master/docs/POSTINSTALL.md

gregelin commented 10 years ago

OK. It is clear from looking at vbkick README and code that postinstall does not execute as part of vbkick build <vmname> command. postinstall is a separate process. From vbkick README.

Create a new vagrant box

vbkick build newVM
vbkick postinstall newVM
vbkick validate newVM
vbkick export newVM

vagrant box add newVM newVM.box
vagrant box list

Also see: https://github.com/wilas/vbkick/issues/60 for more details.