Vagrant + Ansible + Oracle

So, I finally got my act together and created the repositories I’ve been meaning to create for ages, to automatically spin up a VM running Oracle.

They are:

and uses Vagrant to provision the machine, and then Ansible to automatically provision Oracle.

The readme’s for each repository should (hopefully) be enough to get going, but in short these are the steps required:

  • Clone the repositories
  • Download the 12.2 binaries and place them in the <reponame>/swrepo directory
  • vagrant up

This will (by default) give you a VM with:

  • Oracle Linux 7.3
  • Single instance 12.2.0.1 (cdb + 1 pdb)
  • Storage on either FS or ASM

If you want to test a different combination of OS version and Oracle version, just follow the instructions in the readme.

The Vagrant boxes are the same ones I talked about in this post.

If you decide to try this and have problems or just have questions, just ask here or open an issue for the corresponding repository.

Advertisements

11 thoughts on “Vagrant + Ansible + Oracle

  1. Hi Mikael,

    I am trying to start VM for single instance and ASM and it fails at step for ansible:

    => db1-asm: Running provisioner: ansible_local…
    `playbook` does not exist on the guest: /vagrant/ansible-oracle/vbox-si-asm-install.yml

    checking cloned directory from github I do not see any files under ansible-oracle directory
    however in github directory exists but with name “ansible-oracle @ d311447”

    Thanks,
    Andrey

    • Hi,

      Did you do ‘git clone –recursive…’?
      If you don’t the submodule doesn’t get sucked in, and then those files won’t exist.

      regards
      /M

      • Hi Mikael,

        I got a new version of scripts (after the change of hosts.yml format) and am trying to create VMs and provision Oracle but playbook fails at steps of restart dnsmasq

        ==> db-asm-1: Running provisioner: ansible_local…
        db-asm-1: Running ansible-playbook…


        RUNNING HANDLER [init : restart dnsmasq] ***************************************
        changed: [db-asm-1]

        PLAY RECAP *********************************************************************
        db-asm-1 : ok=8 changed=6 unreachable=0 failed=0

        I just finishes w/o errors/failures and not going further. I tried ol73, ol68 with 12.1 and 12.2
        but result the same. I am not sure what might be the issue

        Cheers,
        Andrey

  2. Pingback: Vagrant? Again? …Really? | oravirt

  3. Here is the output:

    [andrey@angor vagrant-vbox-si-asm]$ vagrant up
    Bringing machine ‘db-asm-1’ up with ‘virtualbox’ provider…
    ==> db-asm-1: Importing base box ‘oravirt/ol68’…
    ==> db-asm-1: Matching MAC address for NAT networking…
    ==> db-asm-1: Checking if box ‘oravirt/ol68’ is up to date…
    ==> db-asm-1: Setting the name of the VM: db-asm-1
    ==> db-asm-1: Clearing any previously set network interfaces…
    ==> db-asm-1: Preparing network interfaces based on configuration…
    db-asm-1: Adapter 1: nat
    db-asm-1: Adapter 2: hostonly
    ==> db-asm-1: Forwarding ports…
    db-asm-1: 22 (guest) => 2222 (host) (adapter 1)
    ==> db-asm-1: Running ‘pre-boot’ VM customizations…
    ==> db-asm-1: Booting VM…
    ==> db-asm-1: Waiting for machine to boot. This may take a few minutes…
    db-asm-1: SSH address: 127.0.0.1:2222
    db-asm-1: SSH username: vagrant
    db-asm-1: SSH auth method: private key
    db-asm-1: Warning: Remote connection disconnect. Retrying…
    ==> db-asm-1: Machine booted and ready!
    ==> db-asm-1: Checking for guest additions in VM…
    db-asm-1: The guest additions on this VM do not match the installed version of
    db-asm-1: VirtualBox! In most cases this is fine, but in rare cases it can
    db-asm-1: prevent things such as shared folders from working properly. If you see
    db-asm-1: shared folder errors, please make sure the guest additions within the
    db-asm-1: virtual machine match the version of VirtualBox you have installed on
    db-asm-1: your host and reload your VM.
    db-asm-1:
    db-asm-1: Guest Additions Version: 5.0.20
    db-asm-1: VirtualBox Version: 5.1
    ==> db-asm-1: Setting hostname…
    ==> db-asm-1: Configuring and enabling network interfaces…
    ==> db-asm-1: Mounting shared folders…
    db-asm-1: /vagrant => /home/andrey/vag/vagrant-vbox-si-asm
    db-asm-1: /media/swrepo => /home/andrey/vag/vagrant-vbox-si-asm/swrepo
    ==> db-asm-1: Running provisioner: network (shell)…
    db-asm-1: Running: inline script
    ==> db-asm-1: Shutting down interface eth0:
    ==> db-asm-1: [ OK ]
    ==> db-asm-1: Shutting down interface eth1:
    ==> db-asm-1: [ OK ]
    ==> db-asm-1: Shutting down loopback interface:
    ==> db-asm-1: [ OK ]
    ==> db-asm-1: Bringing up loopback interface:
    ==> db-asm-1: [ OK ]
    ==> db-asm-1: Bringing up interface eth0:
    ==> db-asm-1: Determining IP information for eth0…
    ==> db-asm-1: done.
    ==> db-asm-1: [ OK ]
    ==> db-asm-1: Bringing up interface eth1:
    ==> db-asm-1: Determining if ip address 192.168.9.62 is already in use for device eth1…
    ==> db-asm-1: [ OK ]
    ==> db-asm-1: Running provisioner: ansible_local…
    db-asm-1: Running ansible-playbook…

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

    TASK [setup] *******************************************************************
    ok: [db-asm-1]

    TASK [init : Install packages] *************************************************
    ok: [db-asm-1] => (item=[u’ntp’, u’dnsmasq’])

    TASK [init : Make sure ntp is running] *****************************************
    changed: [db-asm-1]

    TASK [init : Generate /etc/hosts] **********************************************
    changed: [db-asm-1]

    TASK [init : Generate /etc/resolv.conf] ****************************************
    changed: [db-asm-1]

    TASK [init : Generate dnsmasq config] ******************************************
    changed: [db-asm-1]

    TASK [init : Start and enable dnsmasq] *****************************************
    changed: [db-asm-1]

    RUNNING HANDLER [init : restart dnsmasq] ***************************************
    changed: [db-asm-1]

    PLAY RECAP *********************************************************************
    db-asm-1 : ok=8 changed=6 unreachable=0 failed=0

    [andrey@angor vagrant-vbox-si-asm]$ vagrant box list
    bento/oracle-6.8 (virtualbox, 2.3.1)
    hashicorp/precise64 (virtualbox, 1.1.0)
    ol73 (virtualbox, 0)
    oravirt/ol68 (virtualbox, 20170418)
    oravirt/ol73 (virtualbox, 20170412)
    oravirt/ol73 (virtualbox, 20170418)

  4. Hi,

    Ok, so that seems to work as expected.

    Now do, ‘setup=true vagrant provision’ (or setup=true vagrant up).
    This changed with the new codebase (The procedure is mentioned in the README, but I’ll also update this blogpost for clarity).

    Let me know if that works for you.

    Also, you can remove the old box-versions (vagrant box remove oravirt/ol73 –box-version 20170412)

    regards
    /Micke

    • Thank you! Now it went through and ansible executed.
      I also noticed that disks being created in directory with vagrant and it filled my home directory
      so I modified the code to create disks under default folder:


      line = `VBoxManage list systemproperties | grep “Default machine folder”`
      vb_machine_folder = line.split(‘:’)[1].strip()

      local_disk_name = File.join(vb_machine_folder, “#{vm[‘hostgroup’]}”, vb.name, “#{vm[‘basename_vm’]}#{v}-#{disk[‘name’]}-#{d}.vdi”)

      Thanks again!

      • Hi again,
        I just added a variable called ‘base_disk_path’ which you could set to your Virtualbox default path and then all disks created by Vagrant end up there instead of the ‘Vagrantfile’ directory.
        So, if your VBOX default is /home/username/VBOX, the disks will end up in /home/username/VBOX/hostgroup/

        regards
        /M

  5. Great!

    No problems, happy to see it being used 😉
    And re the disks: They were also previously created in the ‘vagrant’ directory, that didn’t change with the new config.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s