What
is Ansible roles ?
1. Ansible roles are consists of many
playbooks, which is similar to modules in puppet and
cook books in chef. We term the same
in ansible as roles.
2. Roles are a way to group multiple
tasks together into one container to do the automation
in very effective manner with clean
directory structures.
3. Roles are set of tasks and
additional files for a certain role which allow you to break up the configurations.
4. It can be easily reuse the codes by
anyone if the role is suitable to someone.
5. It can be easily modify and will reduce the syntax
errors.
Directory
structure for a role:
tasks - contains the main list of
tasks to be executed by the role.
handlers - contains handlers, which
may be used by this role or even anywhere outside this role.
defaults - default variables for the
role.
vars - other variables for the role.
Vars has the higher priority than defaults.
files - contains files required to
transfer or deployed to the target machines via this role.
templates - contains templates which
can be deployed via this role.
meta - defines some data / information
about this role (author, dependency, versions, examples, etc,.)
Ansible Lab:
In this tutorial we will discuss weblogic 12c installation and
configuration using Ansible roles.
Clone the project repo to your Ansible control machine.
git
clone https://github.com/stardomsolutions/ansible-weblogic12c.git
Follow below steps before running the playbook.
1) Download jdk-8u66-linux-x64.tar.gz and place it in
roles/linux-jdk/files/
2) Download fmw_12.2.1.2.0_infrastructure.jar and place it
in roles/fmw-software/files/
3) Update infra-vars.yml and secrets.yml files as per your requirement in
project root folder.
4) Update the hosts file as per your target environment.
Finally run the below command to install weblogic 12c on target machine.
remote username should have sudo access to install required packages and
softwares.
ansible-playbook weblogic-fmw-domain.yml -k -k -u
<remote_username>
Code
Explanation:
weblogic-fmw-domain.yml
is the main playbook from which we will invoke different ansible roles to
install weblogic 12c.
infra-vars.yml, wls-vars.yml, secrets.yml
are the user defined variables in which we can pass user inputs.
linux-wls : to install and configure all OS
Prerequisites to install weblogic 12c like
Installing required packages
Changing firewald configurations.
Creating users and groups
Creating directory structure
linux-jdk
: to install JDK
fmw-software
: to install weblogic 12c
fmw-domain
: to create domain
node-manager
: to configure nodemanager
start-admin-server
: to start admin server
fmw-managed-server
: to start manage server
No comments:
Post a Comment