[英]playbook need to check java version and if the java version below 1.8* version then playbook install java 1.8*
i wrote the below code but not succeed to install java 1.8 version in target server.我写了下面的代码,但没有成功在目标服务器上安装 java 1.8 版本。 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 Ansible 状态会处理上述版本是否存在
Note:- Kindly use proper formatting in the question注意:-请在问题中使用正确的格式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.