脚本功能:安装jdk

测试环境:CentOS6.7

说明:

1、卸载系统自带的openjdk,重新安装Oracle jdk,支持Hotspot,性能更好,更稳定。

2、jdk软件包按文档说明进行定制(按要求重新压缩下)

 1 ---
 2 - name: JDK install and configuration
 3   hosts: '{{ host }}'
 4   
 5   tasks:
 6     - name: remove the openjdk
 7       yum: name=*-openjdk-* state=absent
 8     - name: remove the gcj
 9       yum: name=*gcj* state=absent
10     - name: set the JAVA_HOME environment
11       lineinfile: dest=/etc/profile regexp="^JAVA_HOME=" line="JAVA_HOME=/usr/local/java"
12     - name: set the PATH environment
13       lineinfile: dest=/etc/profile regexp="^PATH=\$PATH:\$JAVA_HOME" line="PATH=$PATH:$JAVA_HOME/bin"
14     - name: set the CLASSPATH environment
15       lineinfile: dest=/etc/profile regexp="^CLASSPATH=" line="CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/sapjco3.jar"
16     - name: set the JRE_HOME environment
17       lineinfile: dest=/etc/profile regexp="^JRE_HOME" line="JRE_HOME=$JAVA_HOME/jre"
18     - name: set the LD_LIBRARY_PATH environment
19       lineinfile: dest=/etc/profile regexp="^LD_LIBRARY_PATH" line="LD_LIBRARY_PATH=dir:$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/amd64/server"
20     - name: export the JAVA_HOME LD_LIBRARY_PATH PATH
21       lineinfile: dest=/etc/profile regexp="^export JAVA_HOME" line="export JAVA_HOME LD_LIBRARY_PATH PATH"
22     - name: download the jdk to remote host
23       get_url: url={{ url }} dest=/tmp/jdk.tar.gz
24     - name: absent old java
25       file: path=/usr/local/java state=absent
26     - name: Create the java install dir
27       file: path=/usr/local/java state=directory
28     - name: install the jdk
29       shell: cd /tmp && tar xzf /tmp/jdk.tar.gz -C /usr/local/java
View Code

相关文章:

  • 2022-02-20
  • 2021-11-22
  • 2022-12-23
  • 2022-02-09
  • 2021-12-29
  • 2021-07-27
  • 2021-07-20
  • 2021-04-24
猜你喜欢
  • 2022-02-23
  • 2021-04-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2021-12-23
相关资源
相似解决方案