Skip links

Deploying Oracle GoldenGate 21c with Ansible

Ansible has become a standard configuration tool for many enterprises and is used is many CI/CD pipelines to build standard implementations with the organizations.  Ansible is a very powerful tool that leveraged secure shell (ssh) to make connect to target hosts and push to the modules needed to build the platform.  Like any tool, Ansible is very flexible and lends itself to the usage of the user.  Software packages like Oracle Database and Oracle GoldenGate can be baked into playbooks providing a standard installation process.

With the latest release of Oracle GoldenGate 21c, RheoData has built a standard template that allows its consultants to quickly build Oracle GoldenGate 21c into any environment.  This blog post, we will look at the playbook and see how Oracle GoldenGate 21c is installed on a Linux host.

Variable File

The first thing that has to be defined is the variables that are going to be used within playbook.  There are different ways of defining variables, but for simplify we used the sub-folder structure (defaults) which house the file main.yml.  Within this main.yml file, all variables needed are defined.  Below is the current consturct of our variables file:

stage_dir: /opt/software/
stage_ogg: /opt/software/ogg19cma
oracle_base: /opt/app/oracle
oracle_inventory: /opt/app/oraInventory
oracle_home_client: /opt/app/oracle/product/client
ogg_home: /opt/app/oracle/product/19.1.0/oggcore_21c
ogg_deployment_home: /opt/app/oracle/gg_deployment
ora_group: oinstall
oracle_user: oracle
root_user: root
ggsoft19c_rsp: oggcore_21c.rsp
installation: Oracle GoldenGate

zip_files: /Users/bocurtis/Build_Software/zip_files/
response_files: /Users/bocurtis/Build_Software/response_files/
script_files: /Users/bocurtis/Build_Software/scripts/

oracle_client_lite_19c: instantclient-basiclite-linux.x64-19.5.0.0.0dbru.zip
oracle_client_lite_18c: instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip
oracle_client_12c: instantclient-basic-linux.x64-12.2.0.1.0.zip
gg_services_software: 213000_fbo_ggs_Linux_x64_services_shiphome.zip

set_passwords: set_passwd.sh
self_sign: ggSelfSignCerts.py
nginx_setup: configureNginx.sh
sm_start: startServiceManager.sh
sm_stop: stopServiceManager.sh

As you review the list of variables that are needed for installing Oracle GoldenGate 21c (above), notice that some of these variables reference scripts that can be used to make managing Oracle GoldenGate 21c a bit easier.  These scripts do not come with Oracle GoldenGate 21c.

Tasks

With the variables defined, the next thing to do is define the tasks that must be done in order to install Oracle GoldenGate 21c.  Just like the variables file, the tasks are provided in a sub-folder structure (tasks).  Within this folder, we only needed another main.yml file, but for step purposes we broke the tasks down further.  With the current tasks, we have a main.yml, copy.yml, and install.yml.  These three file cover all the steps needed to install Oracle GoldenGate 21c within a single host.  Lets take a look at these now:

main.yml

The main.yml file for Tasks, is the main file that will drive all of the installation.  This file uses all variables that was defined earlier.

---
- name: Display Pre-Install Message
remote_user: "{{ root_user }}"
become: yes
debug:
msg:
- '{{ installation }} Installation started at {{ ansible_date_time.time }}:'
- name: Update RPM Packages
remote_user: "{{ root_user }}"
become: yes
yum:
name: "*"
state: latest
- name: Install Oracle Pre-Requistes
remote_user: "{{ root_user }}"
become: yes
yum:
name: oracle-database-preinstall-19c
state: latest
- name: Create required directories
remote_user: "{{ root_user }}"
become: yes
file: path="{{ item }}" state=directory owner="{{ oracle_user }}" group="{{ ora_group }}" mode=0755
with_items:
- "{{ stage_dir }}"
- "{{ stage_ogg }}"
- "{{ oracle_base }}"
- "{{ oracle_inventory }}"
- "{{ oracle_home_client }}"
- "{{ ogg_home }}"
- "{{ ogg_home_18c }}"
- "{{ ogg_deployment_home }}"
tags:
- ogg19c_directories
- name: tasks/copy.yaml instead of 'main'
import_role:
name: gg19cSetup
tasks_from: copy
- name: tasks/install.yaml instead of 'main'
import_role:
name: gg19cSetup
tasks_from: install
- name: Display Post-Install Message
remote_user: "{{ root_user }}"
become: yes
debug:
msg:
- '{{ installation }} Installation finished at {{ ansible_date_time.time }}:'
...
copy.yml

The copy task is called from the main.yml file and used to copy the needed binaries and files to the target host.  At the same time set the permissions needed on these files.

---
- name: Coping required files
remote_user: "{{ root_user }}"
become: yes
copy:
src: "{{ item }}"
dest: "{{ stage_dir }}"
owner: "{{ oracle_user }}"
group: "{{ ora_group }}"
mode: 0555
with_items:
- "{{ response_files }}{{ggsoft21c_rsp}}"
- "{{ zip_files }}{{ oracle_client_lite_19c }}"
- "{{ zip_files }}{{ oracle_client_lite_18c }}"
- "{{ zip_files }}{{ oracle_client_12c }}"
- "{{ zip_files }}{{ gg_services_software }}"
- "{{ script_files }}{{ set_passwords }}"
- "{{ script_files }}{{ self_sign }}"
- "{{ script_files }}{{ nginx_setup }}"
- "{{ script_files }}{{ sm_start }}"
- "{{ script_files }}{{ sm_stop }}"
...
install.yml

The install task is called from the main.yml file and begins to perform the install Oracle GoldenGate 21c.  The task does everything from unzipping the Oracle Client libraries and Oracle GoldenGate 21c, through configuring the .bashrc environment.

---
- name: Unzipping/Installing Oracle Database Client 19c
remote_user: "{{ root_user }}"
become: yes
become_user: "{{ oracle_user }}"
unarchive:
src: "{{ stage_dir }}{{ oracle_client_lite_19c }}"
dest: "{{ oracle_home_client }}"
extra_opts: 
- --j
remote_src: true
- name: Unzipping/Installing Oracle Database Client 18c
remote_user: "{{ root_user }}"
become: yes
become_user: "{{ oracle_user }}"
unarchive:
src: "{{ stage_dir }}{{ oracle_client_lite_18c }}"
dest: "{{ oracle_home_client }}"
extra_opts:
- --j
remote_src: true
- name: Unzipping Oracle GoldenGate 21c
remote_user: "{{ root_user }}"
become: yes
become_user: "{{ oracle_user }}"
unarchive:
src: "{{ stage_dir }}{{ gg_services_software }}"
dest: "{{ stage_ogg }}"
remote_src: true
- name: Installing Oracle GoldenGate 21c for Oracle Database 21c
remote_user: "{{ root_user }}"
become: yes
become_user: "{{ oracle_user }}"
shell: 
cmd: "{{ stage_ogg }}/fbo_ggs_Linux_x64_services_shiphome/Disk1/runInstaller -silent -showProgress -ignoreSysPrereqs -waitForCompletion -responseFile {{ stage_dir }}{{ ggsoft21c_rsp }} >> /tmp/ggInstall.log"
ignore_errors: true
- name: Running root script
remote_user: "{{ root_user }}"
become: yes
shell:
cmd: /opt/app/oraInventory/orainstRoot.sh >> /tmp/ggInstall.log
- name: Setting Passwords
remote_user: "{{ root_user }}"
become: yes
shell:
cmd: "{{ stage_dir }}{{ set_passwords }}"
- name: Setting .bashrc
remote_user: "{{ root_user }}"
become: yes
blockinfile:
dest: /home/oracle/.bashrc
block: |
export OGG_HOME={{ ogg_home }}
export ORACLE_HOME={{ oracle_home_client }}
export ORACLE_BASE={{ oracle_base }}
export LD_LIBRARY_PATH={{ ogg_home }}/lib
export PATH=$OGG_HOME/bin:$LD_LIBRARY_PATH:$PATH
insertbefore: BOF
create: yes
backup: no
...

Once the playbook is done, a fully functioning Oracle GoldenGate 21 environment is installed and ready to use.  Aft this point, other Oracle GoldenGate 21c components can be created using either the command line (AdminClient), the HTML pages, or REST api.

Summary

Through this post, we were showing you how you can use Ansible to install Oracle GoldenGate 21c.  Using this process, Oracle GoldenGate 21c can be installed on any platform in an automated fashion.