Ansible roles Practice-Installing Java

Source: Internet
Author: User
Tags ansible roles

1, Tasks/main.yml

---
-Name:mkdir Necessary Directory
File:path=/usr/java/state=directory mode=0755
-Name:unzip JDK
unarchive:src={{Jdk_package_name}} dest=/usr/java/
-Name:set Env
lineinfile:dest={{Env_file}} insertafter={{item.position}} line={{Item.value}} state=present
With_items:
-{position:eof,value: "\ n"}
-{position:eof,value: "Export java_home=/usr/java/{{Jdk_version}}"}
-{position:eof,value: "Export path= $JAVA _home/bin/: $PATH"}
-{position:eof,value: "Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar"}
-Name:enforce Env
Shell:source {{Env_file}}

2, Vars/main.yml

---
Jdk_package_name:jdk-8u121-linux-x64.tar.gz
Env_file:/etc/profile
jdk_version:jdk1.8.0_121

3. Entrance JDK.YML

---
-hosts:172.16.2.241
Remote_user:root
Roles
-JDK

Ansible roles Practice-Installing Java

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.