Ansible-oracle, the next step

So, I’ve been adding support for GI role separation to the roles so that is why it has taken so long to get this post out.

In the last post we created a single instance database with database storage on a filesystem. This time we’re going to take it a step further and create a single instance database, but now we’re going to use ASM for storage. This means we also have to install the Grid Infrastructure in a stand alone configuration, so we’re adding a few other roles to the playbook.
We’re also going to deploy this configuration on 2 machines in parallel (oradb01, oradb02).

We’re also going to deviate from the default ‘role configuration’, i.e not relying entirely on variable values in defaults/main.yml. You could of course change the default so they more suit your needs and just rely on the defaults, but that limits your options (unless you only have one system to deal with).
The easiest way to override the defaults is to ‘move’ the parameters to a higher priority location, i.e group_vars or host_vars. In this example we’re going to put our ‘host-group’ specifics in group_vars.

So what do I mean by specifics?

  • Storage config (storage devices for filesystems. This time, we’re going to put /u01 on its own device instead of the ‘root’-device)
  • Storage config (storage devices for ASM)
  • We’re going to call the database something else.
  • We may want to install a different versions of GI (or DB). So, this time we’re going to install 12.1.0.2 GI and a 11.2.0.4 database

This is where everything will be installed:

  • GI – /u01/app/oracle/12.1.0.2/grid
  • DB – /u01/app/oracle/11.2.0.4/myhomeasm

A lot of changes have been committed since the last post, so I’m going to clone the repo one more time.
Note: You could also just do a ‘git pull’ to get the latest changes

Clone the repository

[miksan@ponderstibbons git]$ git clone http://github.com/oravirt/ansible-oracle.git
Cloning into 'ansible-oracle'...
remote: Counting objects: 705, done.
remote: Compressing objects: 100% (37/37), done.
remote: Total 705 (delta 7), reused 0 (delta 0)
Receiving objects: 100% (705/705), 208.67 KiB | 0 bytes/s, done.
Resolving deltas: 100% (274/274), done.
Checking connectivity... done.
[miksan@ponderstibbons git]$ cd ansible-oracle/
[miksan@ponderstibbons ansible-oracle]$ ll 
total 104 
-rwxrwxr-x. 1 miksan miksan 1092 Oct 7 09:27 clean.sh 
drwxrwxr-x. 5 miksan miksan 4096 Oct 7 09:27 common 
-rw-rw-r--. 1 miksan miksan 133 Oct 7 09:27 delete-db.yml 
-rw-rw-r--. 1 miksan miksan 494 Oct 7 09:27 full-rac-install.yml 
drwxrwxr-x. 2 miksan miksan 4096 Oct 7 09:27 group_vars 
drwxrwxr-x. 2 miksan miksan 4096 Oct 7 09:27 host_vars 
drwxrwxr-x. 2 miksan miksan 4096 Oct 7 09:27 inventory 
drwxrwxr-x. 4 miksan miksan 4096 Oct 7 09:27 oraasm-configureasm 
drwxrwxr-x. 4 miksan miksan 4096 Oct 7 09:27 oraasm-createdg 
drwxrwxr-x. 5 miksan miksan 4096 Oct 7 09:27 oradb-create 
drwxrwxr-x. 4 miksan miksan 4096 Oct 7 09:27 oradb-delete 
drwxrwxr-x. 7 miksan miksan 4096 Oct 7 09:27 orahost 
drwxrwxr-x. 6 miksan miksan 4096 Oct 7 09:27 orahost-storage 
drwxrwxr-x. 3 miksan miksan 4096 Oct 7 09:27 oralsnr 
drwxrwxr-x. 5 miksan miksan 4096 Oct 7 09:27 oraswdb-install 
drwxrwxr-x. 6 miksan miksan 4096 Oct 7 09:27 oraswgi-clone 
drwxrwxr-x. 5 miksan miksan 4096 Oct 7 09:27 oraswgi-install 
drwxrwxr-x. 3 miksan miksan 4096 Oct 7 09:27 oraswgi-opatch 
drwxrwxr-x. 5 miksan miksan 4096 Oct 7 09:27 oraswracdb-clone
-rw-rw-r--. 1 miksan miksan 9686 Oct 7 09:27 parameters
-rw-rw-r--. 1 miksan miksan 5086 Oct 7 09:27 README.md
-rw-rw-r--. 1 miksan miksan 494 Oct 7 09:27 single-instance-db-on-asm.yml
-rw-rw-r--. 1 miksan miksan 281 Oct 7 09:27 single-instance-db-on-fs.yml
[miksan@ponderstibbons ansible-oracle]$

Add the new group and the hosts belonging to that group

[miksan@ponderstibbons-vm roles]$ vi inventory/hosts 
[miksan@ponderstibbons-vm roles]$ cat inventory/hosts 
[mygroup]
oradb03

[mygroupasm]
oradb01
oradb02

[miksan@ponderstibbons-vm roles]$

Create the playbook

We will use the following roles for this configuration

  • common – Installs a few nice-to-have packages
  • orahost –  Creates the user(s), configures kernel settings, installs packages etc
  • orahost-storage – Partitions and labels the devices to be used by ASM
  • oraswgi-install – Installs Grid Infrastructure and creates the first diskgroup
  • oraasm-createdg – Creates the rest of the diskgroups (if any)
  • oraswdb-install – Installs the database server(s)
  • oradb-create – Creates the database(s)

The roles in bold are what we need to get GI installed and configured.

The playbook is called single-instance-db-on-asm.yml

---
- name: Host configuration
  hosts: mygroupasm
  user: ansible
  sudo: yes
  roles:
     - common
     - orahost
     - orahost-storage

- name: Oracle Grid Infrastructure installation & ASM Configuration
  hosts: mygroupasm
  user: ansible
  sudo: yes
  roles:
     - oraswgi-install
     - oraasm-createdg

- name: Database Server Installation & Database Creation
  hosts: mygroupasm
  user: ansible
  sudo: yes
  roles:
     - oraswdb-install
     - oradb-create

Parameter changes

There are a number of parameters that you might have to change and the easiest way to do that is to put them in group_vars/mygroupasm. By doing that, you’re overriding the defaults for those variables. The rest will use the default values. So even though the following list is not super long there are quite a few other parameters that are in use.

Note: The variable configure_cluster is present below but it has its default value. The reason I also added that to group_vars/mygroupasm is to make you aware of it. Setting that variable to false short-circuits all the variables that make sense when setting up GI in a clustered config (like not looking up cluster-members, scan etc). It also changes the ORACLE_HOME path for GI when in standalone mode.

---

 oracle_install_version_gi: 12.1.0.2
 configure_cluster: false

 configure_host_disks: true
 host_fs_layout: 
   u01:
     {mntp: /u01, device: /dev/sdb, vgname: vgora, pvname: /dev/sdb1, lvname: lvora}

 oracle_asm_crs_diskgroup: crs
 asm_diskgroups: 
   - crs
   - data
   - fra

 asm_storage_layout: 
   crs:
     - {device: /dev/sdc, asmlabel: CRS01}
   data:
     - {device: /dev/sdd, asmlabel: DATA01}
   fra:
     - {device: /dev/sde, asmlabel: FRA01 }

 oracle_dbf_dir_asm: "DATA" 
 oracle_reco_dir_asm: "FRA" 

 oracle_sw_image_db:
# - { filename: linuxamd64_12102_database_1of2.zip, version: 12.1.0.2 }
# - { filename: linuxamd64_12102_database_2of2.zip, version: 12.1.0.2 }
# - { filename: linuxamd64_12c_database_1of2.zip, version: 12.1.0.1 }
# - { filename: linuxamd64_12c_database_2of2.zip, version: 12.1.0.1 }
 - { filename: p13390677_112040_Linux-x86-64_1of7.zip, version: 11.2.0.4 }
 - { filename: p13390677_112040_Linux-x86-64_2of7.zip, version: 11.2.0.4 }

 oracle_databases: 
   myhomeasm: 
      oracle_version_db: 11.2.0.4 
      oracle_edition: EE 
      oracle_db_name: asmdb 
      oracle_db_passwd: Oracle123 
      oracle_db_type: SI 
      is_container: "false" 
      is_racone: "false" 
      storage_type: ASM 
      service_name: asmdb_serv 
      oracle_init_params: "open_cursors=300,processes=700" 
      oracle_db_mem_percent: 30 
      oracle_database_type: MULTIPURPOSE 
      redolog_size_in_mb: 100
      delete_db: false

And with all that in place, its time to deploy the config

[miksan@ponderstibbons ansible-oracle]$ time ansible-playbook my-single-instance-on-asm-install.yml -i inventory/hosts 
PLAY [Host configuration] ***************************************************** 
GATHERING FACTS *************************************************************** 
The authenticity of host 'oradb01 (192.168.0.51)' can't be established.
RSA key fingerprint is 1a:df:30:0b:c5:2e:f2:04:8f:69:14:2f:11:08:cb:bf.
Are you sure you want to continue connecting (yes/no)? yes
The authenticity of host 'oradb02 (192.168.0.52)' can't be established.
RSA key fingerprint is c6:d9:a9:2b:0f:44:1c:10:8d:b4:25:41:ac:34:cf:ec.
Are you sure you want to continue connecting (yes/no)? yes
ok: [oradb01]
ok: [oradb02]

TASK: [common | Install EPEL Repo] ******************************************** 
ok: [oradb01]
ok: [oradb02]

TASK: [common | Get newest repo-file for OL6 (public-yum)] ******************** 
ok: [oradb01]
ok: [oradb02]

TASK: [common | Install common packages] ************************************** 
changed: [oradb02] => (item=screen,facter,procps,module-init-tools,ethtool,bc,bind-utils,nfs-utils,make,sysstat,openssh-clients,compat-libcap1,twm,collectl,rlwrap,tigervnc-server,ntp,expect,git)
changed: [oradb01] => (item=screen,facter,procps,module-init-tools,ethtool,bc,bind-utils,nfs-utils,make,sysstat,openssh-clients,compat-libcap1,twm,collectl,rlwrap,tigervnc-server,ntp,expect,git)

TASK: [common | Start and enable NTP] ***************************************** 
ok: [oradb01]
ok: [oradb02]

TASK: [orahost | User | Add group(s)] ***************************************** 
changed: [oradb01] => (item={'gid': 11000, 'group': 'oinstall'})
changed: [oradb02] => (item={'gid': 11000, 'group': 'oinstall'})
changed: [oradb01] => (item={'gid': 11001, 'group': 'dba'})
changed: [oradb02] => (item={'gid': 11001, 'group': 'dba'})
changed: [oradb01] => (item={'gid': 11002, 'group': 'oper'})
changed: [oradb02] => (item={'gid': 11002, 'group': 'oper'})
changed: [oradb01] => (item={'gid': 11003, 'group': 'asmadmin'})
changed: [oradb02] => (item={'gid': 11003, 'group': 'asmadmin'})
changed: [oradb01] => (item={'gid': 11004, 'group': 'asmdba'})
changed: [oradb02] => (item={'gid': 11004, 'group': 'asmdba'})
changed: [oradb01] => (item={'gid': 11005, 'group': 'asmoper'})
.
.
... SKIP A BUNCH OF LINES
.
.
TASK: [orahost-storage | ASMlib | List ASM disks] ***************************** 
changed: [oradb02]
changed: [oradb01]
TASK: [orahost-storage | List ASM disks] **************************************
ok: [oradb02] => {
 "listdisks.stdout_lines": [
 "CRS01", 
 "DATA01", 
 "FRA01"
 ]
}
ok: [oradb01] => {
 "listdisks.stdout_lines": [
 "CRS01", 
 "DATA01", 
 "FRA01"
 ]
}
PLAY [Oracle Grid Infrastructure installation & ASM Configuration] ************ 
GATHERING FACTS *************************************************************** 
ok: [oradb01]
ok: [oradb02]
TASK: [oraswgi-install | Check if GI is already installed] ******************** 
changed: [oradb01]
changed: [oradb02]
.
.
. SKIP A BUNCH OF LINES
.
.
TASK: [oraswgi-install | Check opatch lsinventory (GI)] *********************** 
changed: [oradb01]
changed: [oradb02]
TASK: [oraswgi-install | debug var=opatchls.stdout_lines] ********************* 
ok: [oradb01] => {
 "opatchls.stdout_lines": [
 "Oracle Interim Patch Installer version 12.1.0.1.3", 
 "Copyright (c) 2014, Oracle Corporation. All rights reserved.", 
 "", 
 "", 
 "Oracle Home : /u01/app/oracle/12.1.0.2/grid", 
 "Central Inventory : /u01/app/oraInventory", 
 " from : /u01/app/oracle/12.1.0.2/grid/oraInst.loc", 
 "OPatch version : 12.1.0.1.3", 
 "OUI version : 12.1.0.2.0", 
 "Log file location : /u01/app/oracle/12.1.0.2/grid/cfgtoollogs/opatch/opatch2014-10-06_23-38-40PM_1.log", 
 "", 
 "Lsinventory Output file location : /u01/app/oracle/12.1.0.2/grid/cfgtoollogs/opatch/lsinv/lsinventory2014-10-06_23-38-40PM.txt", 
 "", 
 "--------------------------------------------------------------------------------", 
 "Installed Top-level Products (1): ", 
 "", 
 "Oracle Grid Infrastructure 12c 12.1.0.2.0", 
 "There are 1 products installed in this Oracle Home.", 
 "", 
 "", 
 "There are no Interim patches installed in this Oracle Home.", 
 "", 
 "", 
 "--------------------------------------------------------------------------------", 
 "", 
 "OPatch succeeded."
 ]
}
ok: [oradb02] => {
 "opatchls.stdout_lines": [
 "Oracle Interim Patch Installer version 12.1.0.1.3", 
 "Copyright (c) 2014, Oracle Corporation. All rights reserved.", 
 "", 
 "", 
 "Oracle Home : /u01/app/oracle/12.1.0.2/grid", 
 "Central Inventory : /u01/app/oraInventory", 
 " from : /u01/app/oracle/12.1.0.2/grid/oraInst.loc", 
 "OPatch version : 12.1.0.1.3", 
 "OUI version : 12.1.0.2.0", 
 "Log file location : /u01/app/oracle/12.1.0.2/grid/cfgtoollogs/opatch/opatch2014-10-06_23-38-41PM_1.log", 
 "", 
 "Lsinventory Output file location : /u01/app/oracle/12.1.0.2/grid/cfgtoollogs/opatch/lsinv/lsinventory2014-10-06_23-38-41PM.txt", 
 "", 
 "--------------------------------------------------------------------------------", 
 "Installed Top-level Products (1): ", 
 "", 
 "Oracle Grid Infrastructure 12c 12.1.0.2.0", 
 "There are 1 products installed in this Oracle Home.", 
 "", 
 "", 
 "There are no Interim patches installed in this Oracle Home.", 
 "", 
 "", 
 "--------------------------------------------------------------------------------", 
 "", 
 "OPatch succeeded."
 ]
}
TASK: [oraasm-createdg | ASMCA | Create script to build asm-diskgroups] ******* 
skipping: [oradb01] => (item=crs)
skipping: [oradb02] => (item=crs)
changed: [oradb01] => (item=data)
changed: [oradb02] => (item=data)
changed: [oradb01] => (item=fra)
changed: [oradb02] => (item=fra)
TASK: [oraasm-createdg | ASMCA | Create ASM diskgroups] *********************** 
skipping: [oradb01] => (item=crs)
skipping: [oradb02] => (item=crs)
changed: [oradb01] => (item=crs)
changed: [oradb02] => (item=data)
changed: [oradb01] => (item=fra)
changed: [oradb02] => (item=fra)
.
.
. SKIP
.
.
PLAY RECAP ******************************************************************** 
oradb01 : ok=105 changed=69 unreachable=0 failed=0 
oradb02 : ok=105 changed=69 unreachable=0 failed=0 


real 36m2.130s
user 0m9.144s
sys 0m6.040s

And after a while we have our database created

[miksan@ponderstibbons ansible-oracle]$ ansible mygroupasm -m shell -a "source ~/.profile_asmdb; /u01/app/oracle/11.2.0.4/myhomeasm/bin/srvctl config database -d asmdb" -i inventory/hosts -u oracle -k
SSH password: 
oradb01 | success | rc=0 >>
Database unique name: asmdb
Database name: asmdb
Oracle home: /u01/app/oracle/11.2.0.4/myhomeasm 
Oracle user: oracle
Spfile: 
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Database instance: asmdb
Disk Groups: 
Services: 

oradb02 | success | rc=0 >>
Database unique name: asmdb
Database name: asmdb
Oracle home: /u01/app/oracle/11.2.0.4/myhomeasm
Oracle user: oracle
Spfile: 
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Database instance: asmdb
Disk Groups: 
Services: 
[miksan@ponderstibbons ansible-oracle]$

That wasn’t so bad, was it? Now we know how to override default parameters without actually changing the defaults.
There are a couple of variables that are used in several roles ($ORACLE_BASE, staging areas etc), and they could be moved to group_vars/all which is ‘global’ to all roles so they don’t need to be in defaults/main.yml for each role.

Next time we’ll set up a RAC install and then we’re also going to use host_vars to set up host specifics (not just group specifics)

Advertisements

One thought on “Ansible-oracle, the next step

  1. Pingback: ansible-oracle, the RAC edition | oravirt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s