您的位置:首页 > 运维架构 > Linux

centos批量部署Java环境

fenglingwan 2020-09-17 21:18 92 查看 https://blog.51cto.com/1167671

Java安装脚本

more /opt/shell/soft/java/install_java.sh

#!/bin/bash
. /root/.bash_profile
set -m
yum -y remove java
echo "开始安装java---------------"
cd /usr/local/src/java
tar -zxvf jdk-8u144-linux-x64.tar.gz -C /opt
chown -R root:root /opt/jdk1.8.0_144
cat >/etc/profile.d/java.sh << EOF
export PATH=$PATH:/opt/jdk1.8.0_144/bin
EOF

ll /opt/shell/soft/java/

total 181356
-rwxr-xr-x 1 root root       283 Jun 21  2019 install_java.sh
-rw-r--r-- 1 root root 185515842 Mar  4  2019 jdk-8u144-linux-x64.tar.gz

ansible-playbook批量安装Java剧本
more /opt/shell/yaml/install_java.yaml

- hosts: "{{ host }}"
tasks:
- name: cpoy java
copy: src=/opt/shell/soft/java dest=/usr/local/src/
- name: install java
shell: /bin/bash /usr/local/src/java/install_java.sh
标签: