ansible自动安装jdk脚本

cat 1.yml
---
- hosts: test1
  gather_facts: no

  tasks:
    - name: tar jdk
   		#压缩包放到主控端的/root下
      unarchive: src=/root/jdk-8u191-linux-x64.tar.gz dest=/usr/local/
    - name: add comment
      shell: echo '#JVAV_HOME SETTING' >> /etc/profile
    - name: exportd JAVA_HOME
      shell: echo 'export JAVA_HOME=/usr/local/jdk1.8.0_191' >> /etc/profile
    - name: exportd CLASSPATH
    # $该符号前面需要加上 \ 转义符
      shell: echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
    - name: exportd PATH
      shell: echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
    - name: source JAVA_HOME
      shell: source /etc/profile

posted @ 2022-05-27 14:47  whtjyt  阅读(83)  评论(0编辑  收藏  举报