wilas / vbkick

Tool for building and maintaining VirtualBox VMs described as a code in a single definition file.
Other
8 stars 5 forks source link

Using post install_launch question #60

Closed gregelin closed 10 years ago

gregelin commented 10 years ago

Is the below duplicative for post install steps?

from vbmachine-cfg

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"
)

from postinstall/adm_context_govready-rhel64.txt

# notgovready-centos-6.5-x86_64-noX-0.2.0
# this is comment
# Note: scripts are exec in order defined here
base.sh
repos.sh
sudo.sh
virtualbox.sh
#ruby.sh
#ansible.sh
#puppet.sh
#chef.sh
#cfengine.sh
rh_devtoolset.sh
rh_software_collections.sh
nfs.sh
cleanup.sh
zerodisk.sh
gregelin commented 10 years ago

Checking testmachines/vbkick-templates/Centos6.5 test machine shows the validate test are failing.

| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/Centos6.5 @ new-host-5 (greg)
| => vbkick validate testmachines_centos65_1409446047139_24869
[INFO] Loading "vbmachine.cfg" definition...
[INFO] Scp: validate
[INFO] Exec: cd validate && bash adm_features.sh adm_context_notgovready-centos-6.5-x86_64-noX-0.2.0.txt
sudo requiretty: FAIL
VBoxControl: FAIL
[INFO] Clean transported: validate

Examination of vbkick testmachines_centos65_1409446047139_24869 shows that Default requiretty is not commented out in /etc/sudoers as it should be. I must have manually commented out file.

So there is a possible error in the vbkick build scripts that is failing to make changes to the /etc/sudoers file.

gregelin commented 10 years ago

Running postinstall script on running vm appears to succeed.

| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4 @ mbair (greg)
| => vbkick ssh testmachines_rhel64db_1409444180555_53101
[INFO] Loading "vbmachine.cfg" definition...
Last login: Sat Aug 30 20:56:21 2014 from 10.0.2.2
[vagrant@vagrant ~]$ exit
logout
________________________________________________________________________________
| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4 @ mbair (greg)
| => vbkick postinstall testmachines_rhel64db_1409444180555_53101
[INFO] Loading "vbmachine.cfg" definition...
[INFO] Scp: postinstall
[INFO] Exec: cd postinstall && sudo bash adm_postinstall.sh adm_context_govready-rhel64.txt
base.sh
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Update Process
No Packages marked for Update
repos.sh
Retrieving http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm
Preparing...                ########################################### [100%]
   1:elrepo-release         ########################################### [100%]
Retrieving http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
sudo.sh
virtualbox.sh
mount: block device /dev/sr1 is write-protected, mounting read-only
/mnt /home/vagrant/postinstall
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.14 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules[  OK  ]
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules[  OK  ]
Doing non-kernel setup of the Guest Additions[  OK  ]
Starting the VirtualBox Guest Additions [  OK  ]
Installing the Window System drivers
Installing X.Org Server 1.13 modules[  OK  ]
Setting up the Window System to use the Guest Additions[  OK  ]
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services components[  OK  ]
/home/vagrant/postinstall
rh_devtoolset.sh
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
elrepo                                                                    | 2.9 kB     00:00
elrepo/primary_db                                                         | 696 kB     00:00
epel/metalink                                                             |  14 kB     00:00
epel                                                                      | 4.4 kB     00:00
epel/primary_db                                                           | 6.3 MB     00:01
Setting up Install Process
Package matching scl-utils-20120229-1.el6.x86_64 already installed. Checking for update.
Resolving Dependencies
--> Running transaction check
---> Package scl-utils-build.x86_64 0:20120229-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
 Package                    Arch              Version                      Repository       Size
=================================================================================================
Installing:
 scl-utils-build            x86_64            20120229-1.el6               epel            6.6 k

Transaction Summary
=================================================================================================
Install       1 Package(s)

Total download size: 6.6 k
Installed size: 2.1 k
Downloading Packages:
scl-utils-build-20120229-1.el6.x86_64.rpm                                 | 6.6 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : scl-utils-build-20120229-1.el6.x86_64                                         1/1
  Verifying  : scl-utils-build-20120229-1.el6.x86_64                                         1/1

Installed:
  scl-utils-build.x86_64 0:20120229-1.el6

Complete!
curl: (22) The requested URL returned error: 404 Not Found
error: https://www.scientificlinux.org/documentation/gpg/RPM-GPG-KEY-sl: import read failed(2).
[INFO] Signal handler - cleanup before exiting...
________________________________________________________________________________
| /codedata/code/GovReady Library/current/testmachines/vbkick-templates/RHEL6.4 @ mbair (greg)
| => vbkick validate testmachines_rhel64db_1409444180555_53101
[INFO] Loading "vbmachine.cfg" definition...
[INFO] Scp: validate
[INFO] Exec: cd validate && bash adm_features.sh adm_context_govready-rhel64.txt
sudo requiretty: OK
Virtualbox Guest Additions: OK
[INFO] Clean transported: validate

So why isn't postinstall scripts running correctly during vbkick install process? And how do I debug it?

gregelin commented 10 years ago

So looking more carefully, it appears postinstall is not automatically run by build? Is that correct?

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
wilas commented 10 years ago

Yes, build and posinstall are 2 separate processes. If you want execute postinstall_launch use vbkick postinstall VM_NAME.

There is of course a way to execute scripts/commands during build process (only if OS support that). I call that "injection" postinstall method. For RHEL base OSes scripts are defined in %post block in kickstart file and processed in chroot environment. For more details please read https://github.com/wilas/vbkick/blob/master/docs/POSTINSTALL.md There is as well SL6_injection_method example in examples directory.

gregelin commented 10 years ago

Thanks @wilas