lunes, 5 de marzo de 2018

Oracle 12c VMs en Windows 10 con Vagrant y Ubuntu (WLS) - errores (2/2)

Continuando con el post anterior, estos son algunos errores posibles si no seguimos los pasos en el orden descrito en el artículo. Seguramente hay muchos más, esto es solo una muestra de lo que puede salir mal en esta configuración (Windows 10.0.16299.192, VirtualBox 5.2.6r120293, Vagrant 2.0.1), así la guía principal de configuración (post anterior) se mantiene simple.

a) Error al intentar iniciar VMs Virtualbox desde Windows

Esto fue luego de actualizar la versión de VirtualBox en Windows de 5.1.4r110228 a 5.2.6.
Al intentar arrancar cualquier VM que ya existía, reportaba este error:

    34b0.21f8: NtCreateFile(\Device\VBoxDrvStub) failed: Unknown Status -5657 (0xffffe9e7) (rcNt=0xe986e9e7)
    VBoxDrvStub error: Not signed with the build certificate.: \Device\HarddiskVolume3\Program Files\Oracle\VirtualBox\VirtualBox.exe

Revisando problemas conocidos encontré esta nota.
Siguiendo las validaciones, en mi caso los drivers eran:

    C:\Users\calero\Downloads>driverquery | findstr /I virtualbox
    VBoxDrv      VirtualBox Service     Kernel        1/15/2018 11:59:22 AM
    VBoxNetAdp   VirtualBox NDIS 6.0 Mi Kernel        1/15/2018 11:59:22 AM
    VBoxNetLwf   VirtualBox NDIS6 Bridg Kernel        1/15/2018 11:59:22 AM
    VBoxUSBMon   VirtualBox USB Monitor Kernel        1/15/2018 11:59:22 AM

Y este es el detalle de VBoxDrv:

    C:\Users\calero>driverquery /v | findstr /I vboxdrv
    VBoxDrv      VirtualBox Service     VirtualBox Service     Kernel        System     Stop Pendi Degraded   TRUE        FALSE        0                 614,400     0          1/15/2018 11:59:22 AM  C:\WINDOWS\system32\DRIVERS\VBoxDrv.sys          4,096

En mi caso lo pude resolver usando la opción de "Reparar la instalación" de programas en Windows.
Esto se hace en "Control Panel\Programs\Programs and Features", buscar "Oracle VM VirtualBox", botón derecho sobre esa entrada y elegir "repair".


b) Error por usar binarios linux de VirtualBox

Si instalan VirtualBox en Ubuntu, cuando lo quieran usar van a tener este error:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ VBoxManage -v
    WARNING: The character device /dev/vboxdrv does not exist.
             Please install the virtualbox-dkms package and the appropriate
             headers, most likely linux-headers-Microsoft.

             You will not be able to start VMs until this problem is fixed.
    5.0.40_Ubuntur115130

Notar que instalé VirtualBox en Ubuntu solo para probar si funcionaba.
A los efectos de la configuración explicada en el post anterior, pueden asumir que esto no lo hicieron, no tienen virtualbox instalado en unbuntu. Yo lo desinstalé antes de instalar Vagrant.
Para ser rigurosos en los pasos que ejecuté, fueron (aunque sin los detalles ya que no aportan para el resultado final):

    sudo apt install virtualbox
    sudo apt-get install virtualbox-dkms
    sudo apt-get purge virtualbox
    sudo dpkg -i vagrant_2.0.1_x86_64.deb  (sólo esto incluí en el post anterior)

   
c) Virtualbox no está en el path al usar Vagrant

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ vagrant up
    The provider 'virtualbox' that was requested to back the machine 'default' is reporting that it isn't usable on this system. The reason is shown below:

    The "VBoxManage.exe" command or one of its dependencies could not be found. Please verify VirtualBox is properly installed. You can verify everything is okay by running "VBoxManage.exe --version" and verifying that the VirtualBox version is outputted.

    If you just installed VirtualBox, you have to log out and log back in for the new environmental variables to take effect. Using the VirtualBox provider within the WSL requires VirtualBox executables to be available on the system PATH.

No necesita explicación, tal como dice el error, ajustando el path se arregla.

   
d) Mezclar ejecuciones de Vagrant desde ubuntu y desde Windows sobre el mismo repo.

Si al clonar el repositorio primero intentamos usarlo desde Windows con 'vagrant up' (ya sabemos que va a fallar), y después vamos a Ubuntu para tratar de usarlo, tenemos este error:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ vagrant up
    The VirtualBox VM was created with a user that doesn't match the
    current user running Vagrant. VirtualBox requires that the same user
    be used to manage the VM that was created. Please re-run Vagrant with
    that user. This is not a Vagrant issue.

    The UID used to create the VM was: 0
    Your UID is: 1000

Los archivos creados en Windows se ven como si fueran de root en ubuntu, pero eso no impide que vagrant funcione:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ id
    uid=1000(ncalero) gid=1000(ncalero) groups=1000(ncalero),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),110(lxd)

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ ls -la
    total 512
    drwxrwxrwx 0 root root   512 Jan 21 13:38 .
    drwxrwxrwx 0 root root   512 Apr 25  2016 ..
    drwxrwxrwx 0 root root   512 Jan 21 13:38 ansible
    drwxrwxrwx 0 root root   512 Jan 21 13:38 .git
    -rwxrwxrwx 1 root root  1231 Jan 21 13:38 README.md
    drwxrwxrwx 0 root root   512 Jan 21 13:55 .vagrant
    -rwxrwxrwx 1 root root 14051 Jan 21 17:52 Vagrantfile
   
Para evitar este error, lo más simple es usar un directorio nuevo para nuestras pruebas en Ubuntu:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ mv .vagrant .vagrant-win

Ahora la ejecución desde Ubuntu con nuestro usuario funciona como se describió en el post anterior:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Box 'bento/oracle-6.9' could not be found. Attempting to find and install...
        default: Box Provider: virtualbox
    ...


e) Error por no configurar las variables de ambiente

Si tratamos de usar vagrant en ubuntu sin configurar las variables de ambiente necesarias, vamos a tener este error:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ vagrant box list
    Vagrant will not operate outside the Windows Subsystem for Linux unless explicitly
    instructed. Due to the inability to enforce expected Linux file ownership and
    permissions on the Windows system, Vagrant will not make modifications to prevent
    unexpected errors. To learn more about this, and the options that are available,
    please refer to the Vagrant documentation:

      https://www.vagrantup.com/docs/other/wsl.html
     

Se arregla fácil configurando las variables descritas en el post anterior.
   
   
f) Error por falta de claves ssh al hacer 'provision'

Si ejecutamos 'vagrant provision' sin tener claves ssh para nuestro usuario:

ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ vagrant provision
    ==> default: Running provisioner: ansible...
    Vagrant has automatically selected the compatibility mode '2.0'
    according to the Ansible version installed (2.4.2.0).

    Alternatively, the compatibility mode can be specified in your Vagrantfile:
    https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

        default: Running ansible-playbook...

    PLAY [all] *********************************************************************

    TASK [install simplejson if needed] ********************************************
    changed: [default]

    PLAY [all] *********************************************************************

    TASK [Gathering Facts] *********************************************************
    ok: [default]

    ...
   
    TASK [setup_linux : copy public key to authorized_key file of root] ************
     [WARNING]: Unable to find '~/.ssh/id_rsa.pub' in expected paths.

    fatal: [default]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'file'. Error was a , original message: could not locate file in lookup: ~/.ssh/id_rsa.pub"}
            to retry, use: --limit @/mnt/d/GitHub/vagrant-builder/ansible/setup.retry

    PLAY RECAP *********************************************************************
    default                    : ok=27   changed=13   unreachable=0    failed=1

    Ansible failed to complete successfully. Any error output should be
    visible above. Please fix these errors and try again.

Esto se resuelve creando la clave ssh como se describe en el post anterior.


No hay comentarios.:

Publicar un comentario