以下是使用Ansible做的一个简单的安装JDK开发环境及设置JDK的环境变量。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@jenkins ansible]
# cat java.yaml
- hosts: newserver
tasks:
- name: java
lineinfile: dest=
/etc/profile
regexp=
"^JAVA_HOME="
line=
"JAVA_HOME=/usr/local/jdk"
- name: java
lineinfile: dest=
/etc/profile
regexp=
"^CLASS_PATH="
line=
"CLASS_PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib"
- name : java
lineinfile: dest=
/etc/profile
regexp=
"^PATH=\$PATH:\$JAVA_HOME"
line=
"PATH=$PATH:$JAVA_HOME/bin"
- name : java
lineinfile : dest=
/etc/profile
regexp=
"^export JAVA_HOME"
line=
"export JAVA_HOME"
- name : java
copy : src=
/app/www/jdk-7u80-ea-bin-b03-linux-x64-19_nov_2014
.
tar
.gz dest=
/tmp/jdk
.tgz
- name : java
file
: path=
/usr/local/jdk
state=absent
- name : java
shell :
cd
/tmp
&&
tar
zxf jdk.tgz &&
mv
jdk1.7.0_80
/usr/local/jdk
|
版权声明:原创作品,如需转载,请注明出处。否则将追究法律责任