We can use the power of ansible to automate the oracle client installation task on multiple servers.In this article, we will explain how we will achieve this by executing an ansible playbook from ansible control node.

 

Ansible control node  is any machine where ansible tool is installed. 

 

IMPORTANT POINTS:

  1. oracle 19c client will be installed on all nodes.
  2. Make sure  the servers where  client need to be installed has connectivity from ansible control server

Below are the steps :

1. Copy the oracle 19c client software ( zip file ) to ansible control server.


[ansible_node] ls -ltr /oracle/LINUX.X64_193000_client.zip

2. Prepare the inventory file:

The list of servers where oracle 19c client will be installed.

[ansiblel_node] $ cat /home/ansible/ansible-scipts/host_inv
[appserver]
linux_host22 ansible_host=10.20.86.60 ansible_connection=ssh ansible_user=root ansible_ssh_pass=dbaclass@123
linux_host29 ansible_host=10.20.86.61 ansible_connection=ssh ansible_user=root ansible_ssh_pass=dbaclass@123
linux_host34 ansible_host=10.20.86.62 ansible_connection=ssh ansible_user=root ansible_ssh_pass=dbaclass@123

3. Prepare the client installation response file:

[ansible_node] $ cat /home/ansible/oracle_client_19c.rsp

#-------------------------------------------------------------------------------
# Do not change the following system generated value.
#-------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_clientinstall_response_schema_v19.0.0

#-------------------------------------------------------------------------------
# Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=oinstall
#-------------------------------------------------------------------------------
# Inventory location.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/oracle/app/oraInventory
#-------------------------------------------------------------------------------
# Complete path of the Oracle Home
#-------------------------------------------------------------------------------
ORACLE_HOME=/oracle/app/oracle/product/19c/client_1
#-------------------------------------------------------------------------------
# Complete path of the Oracle Base.
#-------------------------------------------------------------------------------
ORACLE_BASE=/oracle/app/oracle
oracle.install.client.installType=Administrator

#-------------------------------------------------------------------------------

4. Prepare the ansible playbook:

[ansible_node] $ cat oracle_client_installation.yml
- hosts: appserver
  strategy: free
  user: bvunix
  become: yes
  become_method: su
  become_user: oracle
  tasks:
    - name: check existance of mount point
      command: mountpoint -q /oracle
      register: volume_stat
      failed_when: False
    - name: Copy client software
      unarchive: src=/oracle/LINUX.X64_193000_client.zip dest=/oracle/
    - name: Copy response file
      copy: src=/home/ansible/oracle_client_19c.rsp dest=/oracle mode=0777
    - name: Install Oracle Client
      command: "/oracle/client/runInstaller -silent -showProgress -ignorePrereq -ignoreSysPrereqs -waitforcompletion -responseFile /oracle/oracle_client_19c.rsp"
      register: client_runinstaller_output
      failed_when: "'Successfully Setup Software' not in client_runinstaller_output.stdout"


5. Execute the playbook:

[ansible-node]$  ansible-playbook oracle_client_installation.yml -i /home/ansible/ansible-scipts/host_inv

PLAY [linux_host22,linux_host29,linux_host34] ***********************************************************************************************************************************
Tuesday 06 July 2021  20:30:15 +0300 (0:00:00.048)       0:00:00.048 **********
Tuesday 06 July 2021  20:30:15 +0300 (0:00:00.011)       0:00:00.060 **********
Tuesday 06 July 2021  20:30:15 +0300 (0:00:00.010)       0:00:00.071 **********

TASK [Gathering Facts] **********************************************************************************************************************************************************
[WARNING]: Module remote_tmp /home/oracle/.ansible/tmp did not exist and was created with a mode of 0700, this may cause issues when running as another user. To avoid this,
create the remote_tmp dir with the correct permissions manually
ok: [linux_host34]
ok: [linux_host22]
Tuesday 06 July 2021  20:30:18 +0300 (0:00:02.977)       0:00:03.048 **********
Tuesday 06 July 2021  20:30:18 +0300 (0:00:00.043)       0:00:03.091 **********

TASK [check existance of mount point] *******************************************************************************************************************************************
changed: [linux_host34]
Tuesday 06 July 2021  20:30:19 +0300 (0:00:01.304)       0:00:04.397 **********
changed: [linux_host22]
Tuesday 06 July 2021  20:30:19 +0300 (0:00:00.088)       0:00:04.486 **********

TASK [Gathering Facts] **********************************************************************************************************************************************************
ok: [linux_host29]
Tuesday 06 July 2021  20:30:20 +0300 (0:00:00.884)       0:00:05.370 **********

TASK [check existance of mount point] *******************************************************************************************************************************************
changed: [linux_host29]
Tuesday 06 July 2021  20:30:21 +0300 (0:00:01.329)       0:00:06.699 **********

TASK [Copy client software] *****************************************************************************************************************************************************
changed: [linux_host34]
Tuesday 06 July 2021  20:31:36 +0300 (0:01:14.560)       0:01:21.259 **********
changed: [linux_host22]
Tuesday 06 July 2021  20:31:38 +0300 (0:00:02.122)       0:01:23.382 **********

TASK [Copy response file] *******************************************************************************************************************************************************
changed: [linux_host34]
Tuesday 06 July 2021  20:31:40 +0300 (0:00:01.840)       0:01:25.222 **********
changed: [linux_host22]
Tuesday 06 July 2021  20:31:41 +0300 (0:00:01.072)       0:01:26.295 **********

TASK [Copy client software] *****************************************************************************************************************************************************
changed: [linux_host29]
Tuesday 06 July 2021  20:31:45 +0300 (0:00:04.660)       0:01:30.956 **********

TASK [Copy response file] *******************************************************************************************************************************************************
changed: [linux_host29]
Tuesday 06 July 2021  20:31:48 +0300 (0:00:02.787)       0:01:33.744 **********

TASK [Install Oracle Client] ****************************************************************************************************************************************************
changed: [linux_host22]
changed: [linux_host34]
changed: [linux_host29]

PLAY RECAP **********************************************************************************************************************************************************************
linux_host22               : ok=5    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
linux_host29               : ok=5    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
linux_host34               : ok=5    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Tuesday 06 July 2021  20:33:33 +0300 (0:01:45.191)       0:03:18.935 **********
===============================================================================
Install Oracle Client -------------------------------------------------------------------------------------------------------------------------------------------------- 105.19s
Copy client software ---------------------------------------------------------------------------------------------------------------------------------------------------- 74.56s
Gathering Facts ---------------------------------------------------------------------------------------------------------------------------------------------------------- 2.98s
Copy response file ------------------------------------------------------------------------------------------------------------------------------------------------------- 2.79s
check existance of mount point ------------------------------------------------------------------------------------------------------------------------------------------- 1.33s

We have successfully installed oracle client on all the mentioned servers.