abessifi.sqlplus
Ansible OSB Role
Description
This Ansible role installs the SQL*PLUS tool for connecting to an Oracle database server.
Supported Systems
- Debian 7/8
- Ubuntu Precise/Trusty
- EL 6/7
Role Dependencies
- None.
Requirements
Software Requirements
- Ansible 1.9 or higher (install with
pip
. Example:sudo pip install ansible==1.9.2
) - Vagrant 1.7 or higher
- The
sshpass
package for SSH password authentication. On Ubuntu/Debian:$ sudo apt-get install sshpass
- Virtualbox
System Requirements
- None.
Role Variables
sqlplus_basic_rpm_package
- RPM package containing basic files needed for OCI, OCCI, and JDBC-OCI apps (default:oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
)sqlplus_bin_rpm_package
- RPM package with extra libraries and executable for SQL*Plus (default:oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
)sqlplus_rpm_download_directory
- Path to the directory for RPM files (default:/srv/files/
)sqlplus_home
- Path to the SQL*PLUS installation directory (default:/usr/lib/oracle/12.1/client64
)sqlplus_basic_rpm_package_url
- URL to download the basic RPM (default:undefined
)sqlplus_bin_rpm_package_url
- URL to download the SQL*PLUS RPM (default:undefined
)proxy_env
- Environment variables for proxy settings (default:dummy_var: dummy_var
)
Available Tags
- None.
Local Facts
- None.
Usage
Installation
First, make sure to download the required RPMs from the Oracle website:
- oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
- oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
Next, transfer the downloaded packages to the remote host (using the sqlplus_rpm_download_directory
parameter). By default, Ansible looks for RPM files in /srv/files/
.
Test Connection
For quick tests, you can use the Docker image sath89/oracle-12c to set up an Oracle 12c database server. Pull the image, create a data directory, and run an oracle-db
container:
$ sudo docker pull sath89/oracle-12c:latest
$ sudo mkdir -p /var/lib/oracledb/data
$ sudo docker run --name oracle-db -d -p 8080:8080 -p 1521:1521 -v /var/lib/oracledb/data:/u01/app/oracle -e DBCA_TOTAL_MEMORY=1024 sath89/oracle-12c
To test the database connection:
$ export ORACLE_SID=xe.oracle.docker
$ sqlplus -L sys/oracle@<DB-SERVER-IP-ADDRESS>/xe.oracle.docker as sysdba
You should see a message saying you are connected to Oracle Database 12c.
Development and Testing
Test with Vagrant
For quick testing, you can set up a VM using Vagrant. You might need to adjust the Vagrantfile for your environment (like system, IP addresses, etc.):
Change the Vagrant box name in the Vagrantfile as needed.
Create the virtual machine:
(host)$ vagrant up --no-provision
Copy the RPM packages to the VM.
Provision the virtual machine:
(host)$ vagrant provision
Run Acceptance Tests
You can run acceptance tests for the role using the test-kitchen
tool. The tests are in the ./test/integration/ directory.
The .kitchen.yml
file contains the testing setup and the tests to run. By default, instances are set up with Ansible and run in Vagrant virtual machines.
To list the instances:
$ kitchen list
To run the default test suite on a CentOS 7 setup, use:
$ kitchen test
Author
This role was created by Ahmed Bessifi, a DevOps enthusiast.
ansible-galaxy install abessifi.sqlplus