Showing posts with label vagrant. Show all posts
Showing posts with label vagrant. Show all posts

Saturday, April 18, 2020

VirtualBox VM was created with a user that doesn't match the current user running Vagrant.

Recently I moved some project files from my old to new laptop and hit this "vagrant up" error

~/projects/vagrant-postgres9.6 $ 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: 303684054
Your UID is: 501


Googling I soon found 


The VirtualBox VM was created with a user that doesn't match the current user running Vagrant. #8630https://github.com/hashicorp/vagrant/issues/8630


and TLDR the fix is a simple mv on the .vagrant file:


~/projects/vagrant-postgres9.6 $ mv .vagrant .vagrant.bak
~/projects/vagrant-postgres9.6 $ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'centos/7'
    default: URL: https://vagrantcloud.com/centos/7

==> default: Adding box 'centos/7' (v1905.1) for provider: virtualbox


NB In case your curious ... for more details around my vagrant postgres setup please see:
I also presented to the Amsterdam Postgres UserGroup last year:


Saturday, August 15, 2015

Learning Chef and Ruby version pain ... rbenv issue 96



I was studiously working through the following chef-solo (knife) training document:




When I hit the following weird looking 'syntax error':


root@knife1:/vagrant# chef-solo -c solo.rb -j web.json
[2015-08-15T13:15:50+00:00] INFO: *** Chef 10.14.2 ***
[2015-08-15T13:15:50+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[phpapp]"] from JSON
[2015-08-15T13:15:50+00:00] INFO: Run List is [recipe[apt], recipe[phpapp]]
[2015-08-15T13:15:50+00:00] INFO: Run List expands to [apt, phpapp]
[2015-08-15T13:15:50+00:00] INFO: Starting Chef Run for knife1
[2015-08-15T13:15:50+00:00] INFO: Running start handlers
[2015-08-15T13:15:50+00:00] INFO: Start handlers complete.


================================================================================
Recipe Compile Error in /vagrant/chef-repo/cookbooks/apt/providers/repository.rb
================================================================================


SyntaxError
-----------
compile error
/vagrant/chef-repo/cookbooks/apt/providers/repository.rb:45: syntax error, unexpected ':', expecting ')'
 so = Mixlib::ShellOut.new(cmd, env: { 'LANG' => 'en_US' })
                                    ^
/vagrant/chef-repo/cookbooks/apt/providers/repository.rb:45: syntax error, unexpected ')', expecting kEND


Cookbook Trace:
---------------
 /vagrant/chef-repo/cookbooks/apt/providers/repository.rb:203:in `class_from_file'


Relevant File Content:
----------------------
/vagrant/chef-repo/cookbooks/apt/providers/repository.rb:


 1:  #
 2:  # Cookbook Name:: apt
 3:  # Provider:: repository
 4:  #
 5:  # Copyright 2010-2011, Chef Software, Inc.
 6:  #
 7:  # Licensed under the Apache License, Version 2.0 (the "License");
 8:  # you may not use this file except in compliance with the License.
 9:  # You may obtain a copy of the License at


[2015-08-15T13:15:50+00:00] ERROR: Running exception handlers
[2015-08-15T13:15:50+00:00] ERROR: Exception handlers complete
[2015-08-15T13:15:50+00:00] FATAL: Stacktrace dumped to /vagrant/chef-solo/chef-stacktrace.out
[2015-08-15T13:15:50+00:00] FATAL: SyntaxError: compile error
/vagrant/chef-repo/cookbooks/apt/providers/repository.rb:45: syntax error, unexpected ':', expecting ')'
 so = Mixlib::ShellOut.new(cmd, env: { 'LANG' => 'en_US' })
                                    ^
/vagrant/chef-repo/cookbooks/apt/providers/repository.rb:45: syntax error, unexpected ')', expecting kEND


After double-checking all my scripts and commands (as I hadn't changed the repository.rb file), I started googling for this error and eventually stumbled across


todd commented on Apr 5, 2014
Narrowed this down - it looks like the recipe is using incompatible syntax with Ruby 1.8 (which I'm assuming is the Ruby version @CADBOT and @nazarhussain are using). Since Ruby 1.8 is not supported by this project, this isn't technically an issue, but I'd be more than happy to put some work in to make this compatible with 1.8.


nazarhussain commented on Apr 7, 2014
todd yes you are right I am using Ruby 1.8. Since its pre-built with Chef-Solo, so you must think to resolve this issue and make this recipe functional for old version of ruby.




Checking my ruby version, yes it was 1.8.x:


root@knife1:/vagrant# ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]


As this was a development/training effort and the build process was scripted via vagrant/provision.sh,  the easiest thing to was to upgrade the base image from Ubuntu 12.x (base ruby version is 1.8) to Ubuntu 14.x (base ruby version is 1.9).


For further details of the Vagrantfile, provision.sh and other setup files please see my github repo:






Wednesday, March 11, 2015

Automated command line setup of Oracle 12c on Centos 6.6 using vagrant and virtualbox .. project ora12base code on github




A little background first ...

All the non-oracle code here is free available via github: https://github.com/dgapitts/ora12base

Although to get this to run you will need to download the oracle software (*.zip and *.rpm) files, which naturally means signing up to oracle.com and agreeing to their EULA.


and now a quick overview of the project ora12base ...

The ora12base project, is a relevantly simple vagrant project to automate setup an Oracle 12c environment running on Centos 6.6.


Here is the Vagrantfile:


~/projects/ora12base $ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :


Vagrant.configure(2) do |config|
 config.vm.box = "opscode_centos-6.6_chef-provisionerless.box"
config.vm.box_url="http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.6_chef-provisionerless.box"
 config.vm.network "public_network", ip: "192.168.0.17"
 config.vm.host_name = "ora12c66"
 config.vm.provider "virtualbox" do |vb|
   vb.memory = "4028"
 end
 config.vm.provision :shell, :path => "provision.sh"
end


Note you can run this with as little as 1024M (1G) of memory, but if you are co-hosting multiple Oracle instances (and possibly ASM), then more memory is better


From your host machine


vagrant up
vagrant ssh


Then run as root the pre-install 12c software (mostly rpm driven):


sudo -i
/vagrant/root_post_vagrant_build.sh


and here are steps this script will perform for you:


[vagrant@ora12c66 ~]$ sudo -i
[root@ora12c66 ~]# cat /vagrant/root_post_vagrant_build.sh
cat /vagrant/root_bash_profile.txt >> ~/.bash_profile


. ~/.bash_profile
groupadd -g 1000 oinstall
useradd -G oinstall -u 2000 oracle


cd /etc/yum.repos.d
wget http://public-yum.oracle.com/public-yum-ol6.repo
wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
yum -y install oracle-rdbms-server-12cR1-preinstall


mkdir -p /u01/product/12.1.0/db_1
mkdir -p /etc/oraInventory
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /etc/oraInventory


cd /vagrant
rpm -ivh redhat-release-6Server-1.noarch.rpm


wget http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
yum -y install rlwrap


Now we can install 12c software as oracle


su - oracle
/vagrant/oracle_post_vagrant_build.sh


and here are steps this script will perform for you:


[root@ora12c66 ~]# su - oracle
[oracle@ora12c66 ~]$ cat /vagrant/oracle_post_vagrant_build.sh
cat /vagrant/oracle_bash_profile.txt >> ~/.bash_profile
. ~/.bash_profile
cp /vagrant/linuxamd64_12c_database_* /tmp
cd /tmp/
unzip linuxamd64_12c_database_1of2.zip
unzip linuxamd64_12c_database_2of2.zip
cd /tmp/database/
./runInstaller -noconfig -silent -responseFile /vagrant/db_install.rsp


[oracle@ora12c66 ~]$ cat /vagrant/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME="`hostname`"
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/etc/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/product/12.1.0/db_1
ORACLE_BASE=/u01
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.BACKUPDBA_GROUP=oinstall
oracle.install.db.DGDBA_GROUP=oinstall
oracle.install.db.KMDBA_GROUP=oinstall
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES


The final step of which is 12c software root.sh commands (i.e. as root again)
/etc/oraInventory/orainstRoot.sh
/u01/product/12.1.0/db_1/root.sh


After checking the installer log, via dbca we can create a 12c database


rm /tmp/linuxamd64_12c_database_*zip
dbca -silent -createDatabase -responseFile  /vagrant/dbca.rsp


and here is the contents of the response file:


[oracle@ora12c66 ~]$ cat /vagrant/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME="`hostname`"
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/etc/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/product/12.1.0/db_1
ORACLE_BASE=/u01
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.BACKUPDBA_GROUP=oinstall
oracle.install.db.DGDBA_GROUP=oinstall
oracle.install.db.KMDBA_GROUP=oinstall
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
[oracle@ora12c66 ~]$ cat /vagrant/dbca.rsp
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
GDBNAME = "orcl12c"
SID = "orcl12c"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "qwe123"
SYSTEMPASSWORD = "qwe123"
SYSMANPASSWORD = "qwe123"
DBSNMPPASSWORD = "qwe123"
CHARACTERSET = "UTF8"
NATIONALCHARACTERSET= "UTF8"


Note if you have issues and need to cleanup after any 12c software failures


rm -Rf /etc/oraInventory/*

rm -Rf /u01/product/12.1.0/db_1/*