Site icon Ron Ekins' – Oracle Technology, DevOps and Kubernetes Blog

Fully automated Oracle 18XE build with Ansible


In this Blog I am going to provide a walthrough of my fully automated Oracle 18 Express Edition (XE) build on a Vagrant managed Oracle Linux VirtualBox virtual machine using Ansible and the Pure Storage FlashArray Ansible collection.

I use vagrant up to start my Oracle VirtualBox virtual machine with the latest Oracle Linux image, the VM is configured to use the Ansible provisioner to automatically run a playbook. e.g.

  # Run Ansible from the Vagrant VM
  config.vm.provision "ansible_local" do |ansible|
    ansible.playbook       = "playbook.yml"
    ansible.verbose        = ""
    ansible.version        = "latest"
    ansible.inventory_path = "inventory"
    ansible.install        = true
    ansible.compatibility_mode = "2.0"
    ansible.limit          = "all" # or only "nodes" group, etc.
    ansible.extra_vars = {
        oraPass: oraPass,
        oraWallet: oraWallet


Once the Oracle Linux VM has started, Ansible, iSCSI and other required packages are installed and upgraded. The playbook uses a number of Ansible roles to setup Linux, Ansible, iSCSI, Oracle and the Pure Storage FlashArray.

Setup Linux

The Setup Linux Role install packages, updates /etc/hosts, /etc/syctl.conf, manages services, creates users and required mount points.

Setup Ansible

The Setup Ansible Role configures the ansible.cfg and Ansible hosts files.

Setup iSCSI

The Setup iSCSI Role installs the the Linux multipath packages, and enables multipath and iSCSI services.

Setup Pure

The Setup Pure Role installs the Pure Storage SDK using pip and then determines the server IQN from the /etc/iscsi/initiatorname.iscsi file.

The role then creates 3 new volumes on the Pure Storage FlashArray and connects them to the Oracle Linux Virtual Machine using the latest Pure Storage Ansible collections.

Pure Storage Ansible Collections

use ansible collections

    - purestorage.flasharray

Create Oracle Home Volume

- name: Create FlashArray Oracle Home Volume
    name: "oracle_home"
    size: "15G"
    fa_url: "{{ faUrl }}"
    api_token: "{{ apiToken }}"

connect oracle home volume

- name: Connect oracle_home Volume
    host: "{{ ansible_hostname }}-iscsi"
    protocol: iscsi
      - "{{ iscsi_iqn }}"
    fa_url: "{{ faUrl }}"
    volume: "oracle_home"
    api_token: "{{ apiToken }}"

determine oraclE home UUID

- name: set oracle_home volume details
    ohUuid: "3624a9370{{ item.value.serial | lower }}"
  with_dict: "{{ array_info.purefa_info.volumes }}"
  when: item.key == "oracle_home"

The playbook then rescan the SCSI bus, updates the /etc/multipath.conf file with the UUID’s, creates ext4 file systems and then mounts the Pure Storage FlashArray volumes.

Note: the UUID prefix 3624a9370 is the Pure Storage identifier.

Setup Oracle

Now we have our new volumes presented to our Oracle Linux virtual machine we can start creating our Oracle 18XE database. To this I am using the Oracle 18c preinstall package to create the required Linux users and groups etc. and the downloaded Oracle database XE RPM file.

I am also installing the pexpect and cx_python and packages to automate interactive sessions and provide the ability to manage with our database from python.

# Install Oracle 18c preinstall package
- name: install 18c preinstall package
    name: "oracle-database-preinstall-18c"

# Install Oracle 18 XE package
- name: install Oracle 18xe package
    name: "oracle-database-xe-18c-1.0-1.x86_64.rpm"

# Install cx_Oracle python package.
- pip:
    name: cx_Oracle

# Install the pexpect python package.
- name: install pexpect python packge
    name: pexpect

My playbook finishes by enabling the Oracle services, configuring the tnsnames.ora file and enabling the HR schema.

In the video below you can watch my accelerated build and see me accessing the FlashArray and querying the Oracle 18XE database using python from my new VM. 
Fully automated Oracle 18XE build

Next task is to upload my example Ansible playbook into my GitHub repo.

[twitter-follow screen_name=’RonEkins’ show_count=’yes’]

Exit mobile version