Apr 11, 2022

Install oracle 19c database software using Ansible

To install Oracle database software task on multiple servers, We can use the power of ansible to automate this task. 

we will explain how we will achieve this by executing an ansible playbook from ansible control node/ ansible server.


Major steps:

1. Copy the oracle 19c to your ansible server

   e.g., /mnt/software/LINUX.X64_193000_db_home.zip

2. Prepare the inventory file as per your requirement

3. Prepare the installation response file ( see in roles)

4. Create the role and Prepare the ansible playbooks along with tasks.

5. Execute the playbook. see below


 -- Creating role in Ansible server

# cd root/work

# ansible-galaxy init oracle19c_install

- oracle19c_install was created successfully


-- See the folder structures of roles

[root@ansible01 oracle19c_install]# pwd

/root/work/roles/oracle19c_install

[root@ansible01 oracle19c_install]# ls -l

total 4

drwxr-xr-x 2 root root   22 Mar 31 09:04 defaults

drwxr-xr-x 2 root root   58 Mar 31 09:04 files

drwxr-xr-x 2 root root   22 Mar 31 09:04 handlers

drwxr-xr-x 2 root root   22 Mar 31 09:04 meta

-rw-r--r-- 1 root root 1328 Mar 31 09:04 README.md

drwxr-xr-x 3 root root   58 Apr 11 11:31 tasks

drwxr-xr-x 2 root root   35 Apr  8 06:40 templates

drwxr-xr-x 2 root root  105 Apr  8 08:50 vars


-- defaults

[root@ansible01 oracle19c_install]# cd defaults/

[root@ansible01 defaults]# ls -l

total 4

-rw-r--r-- 1 root root 61 Mar 31 09:04 main.yml

[root@ansible01 defaults]# cat main.yml

---

# defaults file - nodata


-- files

[root@ansible01 files]# pwd

/root/work/roles/oracle19c_install/files

[root@ansible01 files]#


-- meta

[root@ansible01 oracle19c_install]# cd meta/

[root@ansible01 meta]# ls -l

total 4

-rw-r--r-- 1 root root 1610 Mar 31 09:04 main.yml

[root@ansible01 meta]# cat main.yml

galaxy_info:

  author: Gouranga

  description: Install Oracle Database 19c software

  company: Oracle


-- handlers

[root@ansible01 oracle19c_install]# cd handlers/

[root@ansible01 handlers]# ls -l

total 4

-rw-r--r-- 1 root root 61 Mar 31 09:04 main.yml

[root@ansible01 handlers]# cat main.yml

---

# handlers file for /etc/ansible/roles/


-- vars

[root@ansible01 vars]# pwd

/root/work/roles/oracle19c_install/vars

[root@ansible01 vars]# ls -l

total 20

-rw-r--r-- 1 root root  581 Apr  8 08:50 main.yml


[root@ansible01 vars]# cat main.yml

oracle_install_group:            "orauser"

mount_directory:                 "/"

root_directory:                  "/mnt/u05"

stage_dir:                       "/mnt/u05/stage"

scripts_directory:               "{{ root_directory }}/app/scripts"

oracle_base:                     /mnt/u05/app/oracle

oracle_home:                     /mnt/u05/app/oracle/product/19c/dbhome_1

oracle_inventory:                /mnt/orauser/app/oraInventory

oracle_user:                     orauser

root_user:                       root

oradbsoft_rsp:                   "19cEE_SoftOnly"


-- templates

[root@ansible01 oracle19c_install]# cd templates

[root@ansible01 templates]# ls -l

total 4

-rw-r--r-- 1 root root 659 Apr  8 06:40 19cEE_SoftOnly.rsp.j2

[root@ansible01 templates]# cat 19cEE_SoftOnly.rsp.j2

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0

oracle.install.option=INSTALL_DB_SWONLY

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION={{ oracle_inventory }}

ORACLE_HOME={{ oracle_home }}

ORACLE_BASE={{ oracle_base }}

oracle.install.db.InstallEdition=EE

oracle.install.db.OSDBA_GROUP=oinstall

oracle.install.db.OSOPER_GROUP=oinstall

oracle.install.db.OSBACKUPDBA_GROUP=oinstall

oracle.install.db.OSDGDBA_GROUP=oinstall

oracle.install.db.OSKMDBA_GROUP=oinstall

oracle.install.db.OSRACDBA_GROUP=oinstall

SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

DECLINE_SECURITY_UPDATES=true

oracle.installer.autoupdates.option=SKIP_UPDATES

[root@ansible01 templates]#


-- Tasks

[root@ansible01 tasks]# pwd

/root/work/roles/oracle19c_install/tasks

[root@ansible01 tasks]# ls -l

-rw-r--r-- 1 root root 2804 Apr 11 11:31 main.yml


[root@ansible01 tasks]# cat main.yml

- name: display pre database software install message

  remote_user: "{{ root_user }}"

  debug:

    msg:

        - 'Oracle Database Software 19c Installation started for Single Instance at {{ansible_date_time.iso8601}}:'


- name: creating installation directories

  when: inventory_hostname in groups['ansible_client']

  file:

    path="{{ item }}"

    state=directory

    mode=0755

  with_items:

    - "{{ oracle_inventory }}"

    - "{{ oracle_base }}"

    - "{{ stage_dir }}"

    - "{{ oracle_home }}"

  tags:

   - createdirectores


- name: Changing  ownership, group and permissions

  file:

    path: "{{ item }}"

    owner: orauser

    group: oinstall

    mode: '0755'

  with_items:

    - "{{ oracle_inventory }}"

    - "{{ oracle_base }}"

    - "{{ stage_dir }}"

    - "{{ oracle_home }}"

  tags:

   - ownershipchange


- name: coping database software from Source to Target hosts

  when: inventory_hostname in groups['ansible_client']

  copy: src=/mnt/software/LINUX.X64_193000_db_home.zip dest=/mnt mode=0777

  tags:

   - copy_software


- name: Unpack Oracle 19c Database Software to the target server

  when: inventory_hostname in groups['ansible_client']

  unarchive:

     src: /mnt/LINUX.X64_193000_db_home.zip

     dest: /mnt/u05/app/oracle/product/19c/dbhome_1

     remote_src: yes

  tags:

   - extractsoftware


- name: Setup Oracle database 19c installation response file

  when: inventory_hostname in groups['ansible_client']

  template: src=roles/oracle19c_install/templates/{{ oradbsoft_rsp }}.rsp.j2 dest={{ stage_dir }}/{{ oradbsoft_rsp }}.rsp mode=0755

  tags:

   - setuprspfile



- name: Verifying Oracle 19c Database Software installation pre-requisites

  when: inventory_hostname in groups['ansible_client']

  become_user: "{{ oracle_user }}"

  shell: "{{ oracle_home }}/runInstaller -executePrereqs -silent -responseFile {{ stage_dir }}/{{ oradbsoft_rsp }}.rsp -noconfig -ignorePrereqFailure"

  ignore_errors: True

  tags:

   - Prereqs


- name: Staring Installation of Oracle 19c Database Software

  when: inventory_hostname in groups['ansible_client']

  become_user: "{{ oracle_user }}"

  shell: "{{ oracle_home }}/runInstaller -silent -responseFile {{ stage_dir }}/{{ oradbsoft_rsp }}.rsp -noconfig -ignorePrereqFailure"

  ignore_errors: True

  register: command_output

- debug:

    var: command_output.stdout_lines

  tags:

   - dbsoft19c_install


- name: Execute orainstroot.sh

  when: inventory_hostname in groups['ansible_client']

  remote_user: "{{ root_user }}"

  shell: "{{ oracle_inventory }}/orainstRoot.sh"

  ignore_errors: True

  tags:

   - db19c_exeorainstroot


- name: Execute root.sh

  when: inventory_hostname in groups['ansible_client']

  command: "{{ oracle_home }}/root.sh -silent"

  become: yes

  become_user: root

  tags:

   - db19c_exeroot


[root@ansible01 tasks]#


-- mail .yml file to call

[root@ansible01 tasks]# pwd

/root/work/roles/oracle19c_install/tasks

[root@ansible01 tasks]# cd ../../..

[root@ansible01 work]# pwd

/root/work

[root@ansible01 work]# ls -l

-rwxr-xr-x 1 root root   75 Mar 31 09:10 oracle19c_rdbmsinstall.yml

drwxr-xr-x 3 root root   35 Mar 31 09:04 roles

drwxr-xr-x 3 root root   25 Apr  1 10:28 weblogic

[root@ansible01 work]# cat oracle19c_rdbmsinstall.yml

- hosts: ansible_client

  user: root


  roles:

   - oracle19c_install

[root@ansible01 work]#


-- calling mail installation .yml file  

# cd /root/work

# ansible-playbook oracle19c_rdbmsinstall.yml --skip-tags=db19c_exeorainstroot,db19c_exeroot

--- during running of play book 

[root@ansible01 work]# ansible-playbook oracle19c_rdbmsinstall.yml --skip-tags=db19c_exeorainstroot,db19c_exeroot


PLAY [ansible_client] **************************************************************************************************************************


TASK [Gathering Facts] *************************************************************************************************************************

ok: [192.168.100.3]


TASK [oracle19c_install : display pre database software install message] *******************************************************************

ok: [192.168.100.3] => {

    "msg": [

        "Oracle Database Software 19c Installation started for Single Instance at 2022-04-11T10:30:21Z:"

    ]

}


TASK [oracle19c_install : create required directories] *************************************************************************************

changed: [192.168.100.3] => (item=/mnt/orauser/app/oraInventory)

changed: [192.168.100.3] => (item=/mnt/u05/app/oracle)

changed: [192.168.100.3] => (item=/mnt/u05/stage)

changed: [192.168.100.3] => (item=/mnt/u05/app/oracle/product/19c/dbhome_1)


TASK [oracle19c_install : Change  ownership, group and permissions] ************************************************************************

ok: [192.168.100.3] => (item=/mnt/orauser/app/oraInventory)

ok: [192.168.100.3] => (item=/mnt/u05/app/oracle)

ok: [192.168.100.3] => (item=/mnt/u05/stage)

ok: [192.168.100.3] => (item=/mnt/u05/app/oracle/product/19c/dbhome_1)


TASK [oracle19c_install : Unpack Oracle 19c Database Software to the target server] ********************************************************

changed: [192.168.100.3]


TASK [oracle19c_install : Setup Oracle database 19c installation response file] ************************************************************

changed: [192.168.100.3]


TASK [oracle19c_install : Verifying Oracle 19c Database Software installation pre-requisites] **********************************************

changed: [192.168.100.3]


TASK [oracle19c_install : Staring Installation of Oracle 19c Database Software] ************************************************************

changed: [192.168.100.3]


TASK [oracle19c_install : debug] ***********************************************************************************************************

ok: [192.168.100.3] => {

    "command_output.stdout_lines": [

        "Launching Oracle Database Setup Wizard...",

        "",

        "The response file for this session can be found at:",

        " /mnt/u05/app/oracle/product/19c/dbhome_1/install/response/db_2022-04-11_10-36-45AM.rsp",

        "",

        "You can find the log of this install session at:",

        " /mnt/orauser/app/oraInventory/logs/InstallActions2022-04-11_10-36-45AM/installActions2022-04-11_10-36-45AM.log",

        "",

        "As a root user, execute the following script(s):",

        "\t1. /mnt/u05/app/oracle/product/19c/dbhome_1/root.sh",

        "",

        "Execute /mnt/u05/app/oracle/product/19c/dbhome_1/root.sh on the following nodes: ",

        "[example03]",

        "",

        "",

        "Successfully Setup Software."

    ]

}


PLAY RECAP *************************************************************************************************************************************

192.168.100.3             : ok=9    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0


-- Run root scripts -- specific to scenario when you don't have root access

Note: You can see, we ignore root related tasks.

[root@example03 oraInventory]# pwd

/mnt/orauser/app/oraInventory

[root@example03 oraInventory]# ls -l orainstRoot.sh

-rwxrwx---. 1 orauser oinstall 1724 Jun 22  2021 orainstRoot.sh


[root@example03 oraInventory]# sh orainstRoot.sh

Changing permissions of /mnt/orauser/app/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.


Changing groupname of /mnt/orauser/app/oraInventory to orauser.

The execution of the script is complete.


[root@example03 dbhome_1]# pwd

/mnt/u05/app/oracle/product/19c/dbhome_1

[root@example03 dbhome_1]# ls -l root.sh

-rwx------. 1 orauser oinstall 673 Apr 11 09:54 root.sh

[root@example03 dbhome_1]# sh root.sh

Check /mnt/u05/app/oracle/product/19c/dbhome_1/install/root_example03_2022-04-11_09-58-57-749501735.log for the output of root script

[root@example03 dbhome_1]#


[root@example03 dbhome_1]# cat /mnt/u05/app/oracle/product/19c/dbhome_1/install/root_example03_2022-04-11_09-58-57-749501735.log

Performing root user operation.


The following environment variables are set as:

    ORACLE_OWNER= orauser

    ORACLE_HOME=  /mnt/u05/app/oracle/product/19c/dbhome_1

   Copying dbhome to /usr/local/bin ...

   Copying oraenv to /usr/local/bin ...

   Copying coraenv to /usr/local/bin ...


Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

Oracle Trace File Analyzer (TFA) is available at : /mnt/u05/app/oracle/product/19c/dbhome_1/bin/tfactl

[root@example03 dbhome_1]#

-- Verify in target server:

[orauser@example03 dbhome_1]$ export ORACLE_HOME=/mnt/u05/app/oracle/product/19c/dbhome_1

[orauser@example03 dbhome_1]$ cd bin

[orauser@example03 bin]$ ./sqlplus


SQL*Plus: Release 19.0.0.0.0 - Production on Mon Apr 11 09:56:09 2022

Version 19.3.0.0.0


Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Enter user-name: 



13 comments:

  1. I lost my job few months back and there was no way to get income for my family, things was so tough and I couldn't get anything for my children, not until a met a recommendation on a page writing how Mr Bernie Wilfred helped a lady in getting a huge amount of profit every 6 working days on trading with his management on the cryptocurrency Market, to be honest I never believe it but I took the risk to take a loan of $1000. and I contacted him unbelievable and I was so happy I earn $12,500 in 6 working days, the most joy is that I can now take care of my family I don't know how to appreciate your good work Mr. Bernie Doran God will continue to bless you for being a life saver I have no way to appreciate you than to tell people about your good services.
For a perfect investment and good strategies contact Mr Bernie Doran via WhatsApp :+1(424)285-0682 or Telegram : @Bernie_doran_fx or Email : Bernie.doranfx01@gmail.com

    ReplyDelete
    Replies
    1. This comment has been removed by a blog administrator.

      Delete
    2. This comment has been removed by a blog administrator.

      Delete
    3. This comment has been removed by a blog administrator.

      Delete
    4. This comment has been removed by a blog administrator.

      Delete
    5. This comment has been removed by a blog administrator.

      Delete
  2. An hacker helped me to spy on my wife’s WhatsApp,mails and every text message that was sent to her iPhone and every deleted messages of the past six months you can message him through this whatsapp number +14106350697 you can also contact him via email at brillianthackers800@gmail.com and you will also testify of the good works.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. QUALITY SSN DOB DL HIGH CREDIT SCORES Leads
    CC with CVV Fullz (USA, UK, CANADA)
    Tutorials & E-Books For Ethical Hacking
    Tools For Everything You Need

    I'm On Telegram = @killhacks & I C Q = 752822040

    Tools & Tutorials Stuff available for
    (Spamming, Carding, Ethical Hacking, LINUX, Programming, Scripting, etc. )
    *Offering complete packages
    *Will guide & teach
    *Invalid stuff will be replaced instantly

    Deals in all kind of Tools, Tutorials, E-books, Leads/Fullz/Pros
    Available 24/7
    FASTEST DELIVERY

    Build Your Own Business with proper guide & Legit Tools
    Always glad to serve

    GOOD LUCK
    Here I'm:
    I C Q = 752822040
    Tele-gram = @killhacks

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete

Translate >>