Friday, December 18, 2015

Oracle BPM Suite 12c Server using Ansible

This article describes a way to automate the installation of Oracle BPM 12.2.1 on Linux 7 server. I'm using Ansible to automate the configuration of Linux server and install the software. I'm also using Vagrant with Oracle Virtual Box to automatically provision a Linux 7 server and run the Ansible playbook on the virtual machine automatically for testing.
You can download the sample code in my GitHub account:

https://github.com/cvezalis/ansible.oracle.bpm.12c

The sample source code contains an Ansible playbook and configuration for Vagrant. Before you run it you need to download the supported JDK 8 installation file (for example jdk-8u66-linux-x64.tar.gz) and put it on roles/linux-jdk/files folder, Fusion Middleware Infrastructure 12.2.1 installation file and put it on roles/fmw-software/files folder and Oracle BPM suite 12.2.1 installation and put it on roles/soa-software/files from Oracle support.
You need to have an Oracle Database up and running. If you do not have one or you want to create one with Ansible you can use my playbook for Oracle Database. Links are at the end of this article.

For run it you need to have installed Ansible, Vagrant and Virtual Box and then just do:

$ vagrant up

Playbook is idempotent so you can run it again in the same server several times to have your server in the expected status.

You can configure your infrastructure parameters on infra-vars.yml. As minimum (if you do not use my ansible playbook for create the database) you need to configure the database connection settings.

You can also set custom passwords on secrets.yml file. For oracle Linux user you need to set the password encrypted. On a Linux system use the following to create the encrypted password:

mkpasswd --method=SHA-512

Playbook contains several roles. A brief description follows for each of them:

- linux-wls
This role configures the Linux system with packages required, configures the kernel parameters and disables firewall and selinux, create the users and groups required for installation, configure limits for the user that will run the SOA domain.

# ==> Configure Linux
- name: Install required libraries
 yum: name={{ item }} state=present
 with_items: packages_list
- name: Disable SELinux
 selinux: state=disabled
- name: Disable Firewall Deamon (firewalld)
 service: name=firewalld state=stopped enabled=no
- name: Change kernel parameters
 sysctl: name="{{ item.key }}" value="{{ item.value }}" state=present
 with_dict: kernel_params

# ==> Create user and groups
- name: Create groups
 group: name={{ oracle_group }} state=present
- name: Create user
 user: name={{ oracle_user }} groups={{ oracle_group }} password={{ oracle_os_user_pass }}
 
# ==> Add open file and process limits for oracle user
- name: Create a shell profile with file and process limits for oracle user
 template: src=oracle-limits.sh dest=/etc/profile.d/

# ==> Add limits for oracle user
- name: Add oracle user limits
 lineinfile: dest=/etc/security/limits.conf line='{{ oracle_user }} {{ item.limit }} {{ item.type}} {{ item.value }}'
 with_items:
 - { limit: 'soft', type: nofile, value: '{{ soft_no_file }}' }
 - { limit: 'hard', type: nofile, value: '{{ hard_no_file }}' }
 - { limit: 'soft', type: nproc, value: '{{ soft_nproc }}' }
 - { limit: 'hard', type: nproc, value: '{{ hard_nproc }}' }

# ==> Create Base Directories
- name: Create Oracle Home directory
 file: state=directory path={{ middleware_home }} owner={{ oracle_user }} group={{ oracle_group }}
- name: Create Domain Home directory
 file: state=directory path={{ domains_home }} owner={{ oracle_user }} group={{ oracle_group }}
- name: Create Applications Home directory
 file: state=directory path={{ applications_home }} owner={{ oracle_user }} group={{ oracle_group }}

- linux-jdk
This role installs the JDK 8 and creates environment variables for user that  runs the SOA domain.

# ==> Install JDK
- name: Copy jdk archive to host
 copy: src={{ jdk_installation_archive }} dest=~/{{ jdk_installation_archive }}
 args:
 force: no
- name: Extract JDK archive
 command: 'tar -xf ~/{{ jdk_installation_archive }} -C {{ oracle_base }}'
 args:
 creates: "{{ jdk_folder }}"
- name: Change ownership of jdk folder
 file: path="{{ jdk_folder }}" owner={{ oracle_user }} group={{ oracle_group }} recurse=yes
- name: Change entropy device for java
 command: "sed -i.bak 's/\\/dev\\/random/\\/dev\\/.\\/urandom/' {{ jdk_folder }}/jre/lib/security/java.security"
- name: Add JAVA_HOME environment variariables in bashrc
 lineinfile: dest='/home/{{ oracle_user }}/.bashrc' line='export JAVA_HOME={{ jdk_folder }}'
- name: Add Java bin folder to path in bashrc
 lineinfile: dest='/home/{{ oracle_user }}/.bashrc' line='export PATH=$PATH:$JAVA_HOME/bin'

- fmw-software
This role installs WebLogic server with Oracle Fusion Middleware Infrastructure software.

# ==> Install Fusions Middleware Infrastructure Software
- name: Create installer directory
 file: state=directory path={{ mw_installer_folder }}
- name: Copy Middleware Installer
 copy: src={{ mw_installer }} dest={{ mw_installer_folder }}
- name: Copy file for silent installation
 template: src=silent-weblogic.txt dest={{ mw_installer_folder }}
- name: Copy OraInst.loc
 template: src=oraInst.loc dest={{ mw_installer_folder }}
- name: Check if installation is already done
 stat: path='{{ middleware_home }}/oracle_common'
 register: mw_folder_exists
- name: execute Weblogic installer
 command: "{{ jdk_folder }}/bin/java -Xms1024m -Xmx1024m -jar {{ mw_installer_folder }}/{{ mw_installer }} -silent -responseFile {{ mw_installer_folder }}/silent-weblogic.txt -invPtrLoc {{ mw_installer_folder }}/oraInst.loc"
 when: mw_folder_exists.stat.exists == False

- soa-software
This role installs Oracle BPM Suite software and creates the required repositories in the database.

- name: Copy soa/bpm installer files
 copy: src={{ soa_installer }} dest={{ mw_installer_folder }}/
 tags:
 - install-soa

- name: Copy soa installer response file
 template: src=soa.installer.rsp dest={{ mw_installer_folder }}/
 tags:
 - install-soa

- name: Check if Soa Suite is already intalled
 stat: path='{{ middleware_home }}/soa'
 register: soa_installation_exists

- name: Run soa software installer
 command: "{{ jdk_folder }}/bin/java -Xms1024m -Xmx1024m -jar {{ mw_installer_folder }}/{{ soa_installer }} -silent -responseFile {{ mw_installer_folder }}/soa.installer.rsp -invPtrLoc {{ mw_installer_folder }}/oraInst.loc"
 when: soa_installation_exists.stat.exists == False
 tags:
 - install-soa

- name: Copy script that creates the soa schemas in database repository
 template: src=create.soa.repo.sh dest={{ mw_installer_folder }}/ mode=755
 tags:
 - soa-repo

- name: Copy response file
 template: src=rcu.soa.rsp dest={{ mw_installer_folder }}/
 tags:
 - soa-repo

- name: Copy passwords file
 template: src=rcu.passwd.txt dest={{ mw_installer_folder }}/
 tags:
 - soa-repo

- name: Execute script for generate soa schemas on database
 shell: '{{ mw_installer_folder }}/create.soa.repo.sh'
 ignore_errors: yes
 tags:
 - soa-repo

- soa-domain
This role creates the WebLogic domain and a managed server with Oracle BPM software. It also configures the datasources to point to the newly created repositories and configures a unix machine and nodemanager for the domain.

# ==> Create new domain
- name: check if domain folder exists
 stat: path={{ domain_home }}
 register: domain_exists

- name: copy create domain python script
 template: src=create-domain.py dest={{ mw_installer_folder }} owner={{ oracle_user }} group={{ oracle_group }}
 tags:
 - create-domain
- name: Execute create domain script
 shell: "{{ weblogic_home }}/common/bin/wlst.sh {{ mw_installer_folder }}/create-domain.py"
 when: domain_exists.stat.exists == False
 tags:
 - create-domain

# ==> Create Environment Variables for Oracle user
#- name: Creates new .bashrc file with system variables
# template: src=.bashrc dest=/home/oracle/.bashrc
- name: Add Oracle Home environment variables
 lineinfile: dest='/home/{{ oracle_user }}/.bashrc' line='export ORACLE_HOME={{ middleware_home }}'
 tags:
 - oracle-vars

- nodemanager
This role configures the nodemanager to start on system boot.

- name: Copy Nodemanager Properties file
 template: src=nodemanager.properties dest={{ domain_home }}/nodemanager/ owner={{ oracle_user }} group={{ oracle_group }}
 tags:
 - start-nodemanager

# ==> Create startup script for nodemanager
- name: Copy nodemanager systemd script
 template: src=nodemanager.service dest=/etc/systemd/system/ mode=0664
 tags:
 - start-nodemanager
- name: Enable nodemanager as linux service
 command: 'systemctl enable nodemanager'
 tags:
 - start-nodemanager
- name: Start Node Manager
 command: 'systemctl start nodemanager'
 tags:
 - start-nodemanager
- name: Waiting for nodemanager to come up
 wait_for: port=5556 delay=2 timeout=30
 tags:
 - start-nodemanager

- start-admin-server
This role starts the AdminServer.

# ==> Ansible Role for start Admin Server and waits until server is up
- name: Create security folder on Admin Server
 file: state=directory path={{ domains_home }}/{{ domain_name }}/servers/{{ admin_server_name }}/security owner={{ oracle_user }} group={{ oracle_group }}
 tags:
 - start-admin-server
- name: Create boot.properties file
 template: src=boot.properties dest={{ domains_home }}/{{ domain_name }}/servers/{{ admin_server_name }}/security/ owner={{ oracle_user }} group={{ oracle_group }}
 tags:
 - start-admin-server
- name: Copy Admin Server start-up script
 template: src=start-admin-server.py dest={{ mw_installer_folder }} owner={{ oracle_user }} group={{ oracle_group }} mode=0755
 tags:
 - start-admin-server
- name: Execute start Admin Server script
 shell: "{{ weblogic_home }}/common/bin/wlst.sh {{ mw_installer_folder }}/start-admin-server.py"
 sudo_user: '{{ oracle_user }}'
 ignore_errors: yes
 tags:
 - start-admin-server
- name: Wait for Admin Server to startup
 wait_for: port={{ admin_server_port }} delay=2 timeout=60
 tags:
 - start-admin-server

- start-managed-server
This role starts the managed server.

# ==> Start managed server
- name: Create security folder for managed server
 file: state=directory path={{ domains_home }}/{{ domain_name }}/servers/{{ managed_server_name }}/security
 tags:
 - start-managed-server
- name: Create boot properties file for managed server
 template: src=boot.properties dest={{ domain_home }}/servers/{{ managed_server_name }}/security/
 tags:
 - start-managed-server
- name: Copy Start Managed Server Script
 template: src=start-managed-server.py dest={{ mw_installer_folder }}
 tags:
 - start-managed-server
- name: Start Managed Server
 shell: "{{ weblogic_home }}/common/bin/wlst.sh {{ mw_installer_folder }}/start-managed-server.py"
 ignore_errors: yes
 tags:
 - start-manged-server
- name: Wait for Managed Server to startup 
 wait_for: host={{ server_hostname }} port={{ managed_server_port }} delay=2 timeout=300
 tags:
 - start-managed-server


You can read more about automating Oracle BPM Suite installation in the Oracle SOA/BPM Suite 12c documentation and also in the following two nice blog posts:

http://docs.oracle.com/middleware/1221/core/INSOA/toc.htm
http://middlewaresnippets.blogspot.gr/2014/08/set-up-12c-soabpm-infrastructure.html
http://biemond.blogspot.gr/2014/08/create-with-wlst-soa-suite-service-bus.html

You can download a playbook for create an Oracle Database using Ansible here:

https://github.com/cvezalis/oracledb-ansible

2 comments:

  1. please guide this scripts will help to install multi node too

    ReplyDelete
  2. I get the following error during the execution of "soa-domain" role.

    wls:/offline/soa1_domain/Server/AdminServer/SSL/AdminServer>cd('/')
    wls:/offline/soa1_domain>cmo.createServer('soa1_server1')
    Error: only getter and setter are supported

    It seems this part of the .py file has a problem.

    "cmo.createServer('{{ managed_server_name }}')"

    Would you be able to advice on this?
    Is this because i need to run this in online mode where i am connected to admin server ?

    Many thanks,
    Prakash

    ReplyDelete

Note: Only a member of this blog may post a comment.