i wrote the below code but not succeed to install java 1.8 version in target server. getting error while executing playbook
---
- hosts: server
name: Fetch Java version
shell: java -version 2>&1 | grep version | awk '{print $3}' | sed 's/"//g'
register: java_version
- name: install java 1.8.* version
yum: name={{item}} state=latest
with_items:
- java-1.8.0-openjdk.x86_64
when: java_version != 1.8.*
Use below code:
---
hosts: server_name
tasks:
- name: install java
yum:
name: java-1.8.0-openjdk.x86_64
state: present
Ansible state will take care if the above version is present or not
Note:- Kindly use proper formatting in the question
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.