Configure multiple oracle instances in a loop

11 views
Skip to first unread message

Christopher Priest

unread,
Apr 12, 2018, 9:49:16 PM4/12/18
to Ansible Project
Hi There,

  I have set up a playbook and two roles ->

   1) The first role sets up the Linux kernel and OS
   2) The second role installs the Oracle software WITH a listener but WITHOUT any instance. This role has checks to terminate if Oracle is already installed

 I am now wanting to set up a role to install multiple Oracle instances ( DEV TEST UAT RCAT etc). I get stuck with the fact that each instance has a different port number for enterprise manager. eg (DEV 5500, TEST 5501 etc). So far, the only way I can see to do this is to not have a common dbca.rsp file but rather have one per instance with the port number hard coded. Also, I want to ensure that prior to attempting to create a database, that the instance being created doesn't already exist. Is this possible while looping?

Regards

  Chris  

J Hawkesworth

unread,
Apr 16, 2018, 8:35:02 AM4/16/18
to Ansible Project

Here's some ideas

You can define a host variable in your ansible inventory file, like this

--

# ansible inventory

# development hosts below here
devdb01 enterprise_manager_port
=5500

# test hosts below here

testdb01 enterprise_manager_port
=5501


and then create a template dbca.rsp file, where instead of the hard-coded port number, you substitute in the value associated with each host (something like this - i've not looked at the format for dbca.rsp but the stuff inside {{ }} will be substituted

enterprise_manager_port_number={{enterprise_manager_port}}


Then, in your playbook, use the `template` module (see http://docs.ansible.com/ansible/latest/modules/template_module.html), instead of just copying over the dbca.rsp, this will substitute in any variables before copying the templated result to your remote machine.

There are lots of ways of setting up variables in ansible - as well has for hosts, you can do the same for groups of hosts, or have default variables applied to specific roles - and other places too.  so its well worth putting aside a few hours to go through the documentation pages and getting an understanding of whats possible.

Hope this helps,

Jon
Reply all
Reply to author
Forward
0 new messages