Monday, November 9, 2015

Using Ansible to install WebLogic 12c R2 (12.2.1) and Fusion Middleware Infastructure on Oracle Linux 7.1

Before a couple of days Oracle release WebLogic 12c R2 (12.2.1). There are a lot of cool features like Java EE 7 support and Multitenancy Support for WebLogic domains. Installation of WebLogic server along with ADF runtime (Fusion Middleware Infrastructure) are not hard but requires a lot of parameters to be configured and a significant time when you need to repeat the actions in multiple virtual machines. Also Infrastructure updates are time consuming. Ansible is a great tool that help us automate this things. This article will demonstrate the creation of a WebLogic domain using Ansible. You can download code in my git hub account:




Fusion Middleware needs a Database repository for storing the required schemas. If you don't have a database already you can use an Ansible playbook i have create to install an Oracle Database 12c automatically. You can download the code here:

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

You can configure your infrastructure variables in infa-vars.yml

You can test the playbook from the extracted folder using:

vagrant up

a virtual machine will be ready in a few minutes with no other interaction. You can access the Enterprise Manager at http://192.168.56.14:7001/em if you use the default settings.

The playbook contains several roles for do the job in a modular way:


linux-wls Role:

This role install the required libraries on Oracle Linux, disables the Security Enhanced Linux and firewall and configures some kernel parameters required for WebLogic to run smoothly. 

# ==> 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

role also creates the required operating system user and groups. After role fixes the oracle user limits for file and process:

# ==> 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 }}' }

Then role creates the base directories for installation.

linux-jdk Role:

linux-jdk role installs the JDK on the Oracle Linux. WebLogic 12c R2 needs JDK8. Download it from Oracle Support and put it on roles/linux-jdk/files folder before you run the playbook. It also changes the device that java uses to create random numbers for overcome the slow response on default device when entropy is not enough. Lastly we create the JAVA_HOME environment variable for oracle user and add the java bin folder to user PATH.

fmw-software Role:

This role installs the Middleware Infrastructure software. You need to download from Oracle support the installer fmw_12.2.1.0.0_infrastuctrure.jar and put it in roles/fmw-software/files before running the playbook. Role generates the response file for silent installation and execute the installer

# ==> Install Fussion 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: 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"

fmw-domain Role:

This role creates the repositories in database and then executes a python script with WLST to create the domain, apply the Enterprise Manager template to domain, set domain mode to production and set weblogic admin username and password and set the data sources to point to our repository.

node-manager Role:

This role configures the and start the nodemanager. Start, stop and crash recovery are enabled. You may refine this configuration on nodemanager.properties file before run the playbook.

# ==> Ansible Role for configure, start and autostart on reboot Node manager
# ==> for a WebLogic 12c R2 Domain on Oracle Linux 7.1
- 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 Role:

This role creates the boot.properties file with weblogic username and password and then runs a script that connects to nodemanager and starts the AdminServer

fmw-managed-server Role:

This role creates a manged server, creates a boot.properties file and then starts the server.

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


28 comments:

  1. Great post! Do these Ansible roles also applicable to 12.1.3 installations, or some modifications are needed ?

    Many thanks,
    Serafeim.

    ReplyDelete
  2. Are only for R2. (12.2.1) I have other playbook in git-hub for 12.1.3. https://github.com/cvezalis/weblogic-ansible.

    ReplyDelete
  3. Hi Christos,
    great article thanks for that. I have a question and would be very pleased if you could give me an answer. I have a Macbook Air with 8GB of RAM and need an OFM 12c environment to prepare for implementation certification. Is your described also possible on Mac OSX ? Do these scripts generate virtual machines that can be run on a Mac/Windows or Linux ? Sorry for these questions but I am not very confirm to ansible :-) - Regards Sascha (raggadaz(at)gmx.de.

    ReplyDelete
    Replies
    1. Yes you can use Ansible on Mac OSX. There are some guides on the web to help you get started with Ansible on Mac OSX or Windows. You can also use a linux virtual machine on OSX only for ansible and run ansible playbooks from that vm.
      Hope this helps

      Delete
    2. Thanks for your reply. Just in the Moment I am building a Oracle Linux 7.1 VM for Virtual Box. After this I will try your blogpost. What requirements do I need ? Only vagrant and dependencies ? Regards Sascha

      Delete
    3. If you will use a dedicated virtual machine for run Ansible playbooks you will only need Ansible installed. Create a second virtual machine using vagrant or using normal installation, ensure that both virtual machines have network connection and then run playbook from Ansible's virtual machine and configure playbook to target the second vm.

      Delete
  4. Hello I am trying to do this in aws. I have made some changes to the vagrantfile, I was able to start an EC2 instance from my laptop with the same resources i.e 4GB and 2 vcpus. The provisioning part is where, I need assitance.

    ReplyDelete
  5. here is my vagrantfile.

    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    Vagrant.require_plugin 'vagrant-aws'
    #Vagrant.require_plugin 'vagrant-omnibus'
    Vagrant.configure("2") do |config|
    #config.omnibus.chef_version = :latest
    config.vm.synced_folder '.', '/vagrant', :disabled => true
    config.vm.box = "dummy"
    config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
    # Provider
    config.vm.provider :aws do |aws, override|
    aws.access_key_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    aws.secret_access_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
    aws.keypair_name = "xxxxxxxxxxxxxxxxxxxx"
    aws.ami = "ami-9abea4fb" #Ubuntu 14.04 LTS
    aws.region = "us-west-2"
    aws.instance_type = "t2.medium"
    aws.security_groups = ["Wide open"]
    override.ssh.username = "ubuntu"
    override.ssh.private_key_path = "C:/Users/oladimeji/.vagrant.d/insecure_private_key"
    aws.tags = {
    'Name' => 'Vagrant_Ansible'
    }
    end
    # Provisioning
    config.vm.provision "ansible" do |ansible|
    ansible.playbook = "weblogic-fmw-domain.yml"
    ansible.inventory_path = "./hosts"
    ansible.limit = 'all'
    end
    end

    ReplyDelete
  6. here is my vagrantfile.

    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    Vagrant.require_plugin 'vagrant-aws'
    #Vagrant.require_plugin 'vagrant-omnibus'
    Vagrant.configure("2") do |config|
    #config.omnibus.chef_version = :latest
    config.vm.synced_folder '.', '/vagrant', :disabled => true
    config.vm.box = "dummy"
    config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
    # Provider
    config.vm.provider :aws do |aws, override|
    aws.access_key_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    aws.secret_access_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
    aws.keypair_name = "xxxxxxxxxxxxxxxxxxxx"
    aws.ami = "ami-9abea4fb" #Ubuntu 14.04 LTS
    aws.region = "us-west-2"
    aws.instance_type = "t2.medium"
    aws.security_groups = ["Wide open"]
    override.ssh.username = "ubuntu"
    override.ssh.private_key_path = "C:/Users/oladimeji/.vagrant.d/insecure_private_key"
    aws.tags = {
    'Name' => 'Vagrant_Ansible'
    }
    end
    # Provisioning
    config.vm.provision "ansible" do |ansible|
    ansible.playbook = "weblogic-fmw-domain.yml"
    ansible.inventory_path = "./hosts"
    ansible.limit = 'all'
    end
    end

    ReplyDelete
  7. Hello I am trying to do this in aws. I have made some changes to the vagrantfile, I was able to start an EC2 instance from my laptop with the same resources i.e 4GB and 2 vcpus. The provisioning part is where, I need assitance.

    ReplyDelete
  8. jdk-8u66-linux-x86.tar.gz....
    Plus i could not find the above tar
    found jdk-8u66-linux-x64.tar.gz

    ReplyDelete
  9. It was a typo in the empty sample file. You should put your x64 jdk inside the files folder and update the file name in infra-vars.yml

    ReplyDelete
  10. As for provisioning you can run the ansible playbook using ansible-playbook command if Vagrant does not run in. There is also a Vagrant provision command to run the provision in a running virtual machine created with vagrant in a latter time.

    ReplyDelete
  11. Hi, please pardon. Newbie here. Does this also install weblogic server itself? I cannot find the reference to fmw_12.2.1.0.0_wls.jar anywhere in the article. Thank you.

    ReplyDelete
  12. Hi, please pardon. Newbie here. Does this also install weblogic server itself? I cannot find the reference to fmw_12.2.1.0.0_wls.jar anywhere in the article. Thank you.

    ReplyDelete
  13. Yes it will install weblogic too.

    ReplyDelete
  14. Hi Chris, thanks. can you tell me where is the weblogic server installation reference? Thank you.

    ReplyDelete
  15. Hi Chris, thanks. can you tell me where is the weblogic server installation reference? Thank you.

    ReplyDelete
    Replies
    1. You can find the installers for WebLogic here http://www.oracle.com/technetwork/middleware/fusion-middleware/downloads/index.html or in Oracle Delivery Cloud here edelivery.oracle.com

      Delete
  16. Are you saying the Fusion middleware jar includes weblogic server as well? I am looking for ways to install only weblogic server without other add ons. Thank you.

    ReplyDelete
    Replies
    1. Yes, use this link to find WebLogic installers without other software http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html

      Delete
  17. Thank you again, Chris. I have the Weblogic Generic Installer. My confusion is that there is only reference to fmw_12.2.1.0.0_infrastructure.jar in the playbook but not fmw_12.2.1.0.0_wls.jar. Does fmw_12.2.1.0.0_infrastructure.jar include WebLogic Server as well?
    Say if I change the playbook to look for fmw_12.2.1.0.0_wls.jar only, what are the Fusion Middleware specific step can I take out / skip in the playbook?

    ReplyDelete
  18. Thank you again, Chris. I have the Weblogic Generic Installer. My confusion is that there is only reference to fmw_12.2.1.0.0_infrastructure.jar in the playbook but not fmw_12.2.1.0.0_wls.jar. Does fmw_12.2.1.0.0_infrastructure.jar include WebLogic Server as well?
    Say if I change the playbook to look for fmw_12.2.1.0.0_wls.jar only, what are the Fusion Middleware specific step can I take out / skip in the playbook?

    ReplyDelete
  19. This playbook is for installing Fusion Middleware Infrastructure. I may create a playbook for WebLogic in the next days. You may also have a look at WebLogic quick installer in the link i provided to you in the previous comment. It's easy to install it using WebLogic Quick installer.

    ReplyDelete
  20. Ok. thank you. I will check that out. and definitely looking forward to your playbook for Weblogic as well. Thank you for the help.

    ReplyDelete
  21. Chris, is there a reason why one would choose the Quick Installer vs the RPM package vs Generic installer ? Thank you.

    ReplyDelete
  22. I'm adapting your playbook to install a simple domain. On Task fmw-domain, I getting error "No Server object with name RCD_Dom, after 'save domain' and 'read domain' (create-domain.py). Can You Help?

    ReplyDelete
  23. this will work for multi node node installation for high availability please guide me how to achieve that

    ReplyDelete

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