Activity 2: Lets install jdk 11 on Redhat 8 machine
- Lets find the manual steps to install openjdk 11 on RedHat 8 Refer Here for documentation to install openjdk 11
- Create a Redhat 8 virtual machine (in any cloud or hypervisor of your choice)
- We have verified that the manual steps are working
sudo yum install java-11-openjdk -y
- For the module for yum Refer Here
- In our lab setup we dont have a redhat 8 node, so lets add the redhat8 node as node2
- Now we need to copy the key from ansible control node to node2
- Refer Here for the changes made
- Now execute the playbook
- For installing java on two distributions of linux, we have used two seperate playbooks and two seperate inventory files which is not a good idea.
- So as approach 1, lets try to write both the tasks in the same file
- When we execute the ansible playbook, we have observed one extra step running
Gathering facts
. - Ansible facts are data related to the remote node which include os, ip addresses, memory, network and many work…. Refer Here
- The module in ansible which can collect information about the node is
setup
Refer Here. - Lets run some adhoc commands to fetch information
- ubuntu instance (node1):
- redhat instance (node2)
- ubuntu instance (node1):
- To to write conditional statements Refer Here
- Refer Here for the changes done and execute the playbook
- When executing ansible-playbook we can see the debug/log information by adding -v or -vv or -vvv, -vvvv
- Exercise:
- Can you make changes in your existing playbook to install node js to work on Redhat 8.