Hi
I want to install java using its source (tar.gz) for number of redhat servers . Can you please give me a little guide ? How can I use ansible for this task and what are the command list ?
For example : I have 10 no.of redhat 7.2 servers and I want to install jdk-9.0.1_linux-x64_bin.tar.gz for all those servers and same time i wanna setup the java class path too.
Thank you
Luke
You could write up everything from scratch. But since this is a common requirement many people have already done that.
I would just use one of those roles, for instance https://github.com/frieder/ansible-role-oraclejdk/blob/master/README.md.
Dick
Hello,
I have 10 no.of redhat 7.2 servers and I want to install jdk-9.0.1_linux-x64_bin.tar.gz for all those servers and same time i wanna setup the java class path too.
you can achieve this task by following these options:
-
First of all you have to do the entry of your 10 redhat server in “/etc/ansible/hosts” file.
e.g;
[ RedhatServer ]
RedhatServer1
RedhatServer2
. . .
. . .
RedhatServer10
-
make above servers passwordless by using Openssh
eg;
step1: generate ssh key on your machine
$ ssh-keygen
Step2: Copy your public key to the servers with ssh-copy-id:
$ ssh-copy-id -i ~/.ssh/id_rsa.pub “name@RedhatServer1”
- use below playbook to deploy Java on all the given machines using source ( tar.gz):
-
It will first download Java by using get_url module in /java folder (you can give your own folder name here).
-
Then it will extract the java tar file by using unarchive module within the java folder.
-
After extracting it will set the classpath to java.
Hello,
Above provided playbook will set the Classpath temporaily.
If you wish to make the entry persistent, you will have to use below task in place of “setup the java class path” task:
- name: setup the java Classpath permanently
lineinfile:
path: ~/.bashrc
line: ‘export CLASSPATH=“/java”:“/java”:“${CLASSPATH}”’
Thanks
Soniya
Thank you all , All your guides are helpful and I was able to achieve my requirement.
Regards
Luke.