Prerequisites
We have already seen in the earlier posts [if not visited yet please do visit] following links:
- Java Installation using ansible playbook
- WebLogic installer unarchive copy response file, oraInst.loc file to remote node
In this post, I've explored on the below mentioned best suitable ansible modules
- command module
- pause module
The command module I've choosen after trying with shell module.
Installing WebLogic is a single command that need to executed in remote node. As we already copied the WebLogic installer and response file, oraInst.loc to /tmp folder of remote nodes, which can be used by command. To give more generic automation solution we need to use the variables in the playbook.
The pause module will pause the playbook execution. To install WebLogic it requires some time to complete the execution of the command, and we need to wait till that so pause after install command is best option to use.
There are some interesting sections in the playbook that we are going to use in this post containing playbook :
Installing WebLogic is a single command that need to executed in remote node. As we already copied the WebLogic installer and response file, oraInst.loc to /tmp folder of remote nodes, which can be used by command. To give more generic automation solution we need to use the variables in the playbook.
The pause module will pause the playbook execution. To install WebLogic it requires some time to complete the execution of the command, and we need to wait till that so pause after install command is best option to use.
Ansible playbook executes command module to install WebLogic |
There are some interesting sections in the playbook that we are going to use in this post containing playbook :
- vars
- debug module
Ansible allows us to use vars with in the playbook and also we can define in separate file, then its reference file can be included in the playbook. There can be global variables which can be reusable in multiple playbooks depends on the roles that requires. We will discuss more on roles in the next post.
When some of the tasks in ansible modules are played then what happened we don't know. To get the insight on that we have debug moduleoption. When debug module used we need to use the printing option with msg and the register variable to send the result or output to stdout. This stdout is raw string so we need to use
Ansible playbook is so simple to write as we are seeing them since two previous posts. If the playbook have multiple times same value required use vars and use them in multiple lines of a task. Here we will be using java_dir, mw_dir, mw_installer and oracle_home.
When some of the tasks in ansible modules are played then what happened we don't know. To get the insight on that we have debug moduleoption. When debug module used we need to use the printing option with msg and the register variable to send the result or output to stdout. This stdout is raw string so we need to use
Ansible playbook is so simple to write as we are seeing them since two previous posts. If the playbook have multiple times same value required use vars and use them in multiple lines of a task. Here we will be using java_dir, mw_dir, mw_installer and oracle_home.
vi wls_install.yml --- - hosts: appservers remote_user: vagrant vars: java_dir: /home/vagrant/jdk1.8.0_172 mw_dir: /tmp mw_installer: fmw_12.2.1.3.0_wls_quick.jar oracle_home: /home/vagrant/fmw tasks: - name: install WebLogic command: "{{ java_dir }}/bin/java -jar {{ mw_dir }}/{{ mw_installer }} -ignoreSysPrereqs -force -novalidation ORACLE_HOME={{ oracle_home }} -responseFile {{ mw_dir }}/wls_install.rsp -invPtrLoc {{ mw_dir }}/oraInst.loc" register: command_result - debug: msg={{ command_result.stdout.split('\n')[:-1]}} - name: Wait for installation complete pause: minutes: 3The execution of WebLogic installation by playbook is simple as shown below:
vagrant@docking ~/wls-auto $ ansible-playbook -i ~/hosts wls_install.yml
Part 2 of screen shot
ansibible-playbook execution for WebLogic installation |
Your valuable feedback is most important to us to improve our next articles. So request you to use the comment box.
Please write your comments and likes about this ansible series. Stay tuned to "WebLogic Tricks & Tips" for another wonderful automation soon.
Reference links
Thanks for the wonderful information.
ReplyDeleteKeep sharing.
DevOps Online Training