In our previous article, we discussed how to install java 8 on CentOS 7. Having the ability to install java 8 from a single command is a wonderous thing. So, in this post, we will see java installation using Ansible playbook or role to do just that.
Install Java 8 with Ansible
We have already created and submitted Ansible Role to install java 8 to Ansible Galaxy, so in this section we will see how to get download role from ansible galaxy into your work-space and how we can use it.
Install or download from Ansible Galaxy:
ansible@localhost$ ansible-galaxy install avinash6784.oracle-java -p ./roles
See Ansible Galaxy help for more options
ansible@localhost$ ansible-galaxy --help
Download from direct github:
Download manually from github like as below,
ansible@localhost$ git clone https://github.com/avinash6784/ansible-oracle-java.git
The code should reside in the roles directory of your ansible playbooks work-space. ( See ansible documentation for more information on roles ), in a folder oracle-java.
Run the playbook:
First create a playbook like as below,
ansible@localhost$ vim test.yml - name: Install Oracle Java hosts: localhost become: true roles: - oracle-java
ansible@localhost$ ansible-playbook -i hosts test.yml