- hosts: hbase
remote_user: root
vars:
AnsibleDir: /opt/ansible
tasks:
- name: delete exists jdk
file: path=/opt/jdk1.8.0_201 state=absent
- name: copy and unzip jdk
unarchive: src={{AnsibleDir}}/roles/jdk/jdk-8u201-linux-x64.tar.gz dest=/opt/
- name: set env
lineinfile: dest=/etc/profile insertafter="{{item.position}}" line="{{item.value}}" state=present
with_items:
- {position: EOF, value: "export JAVA_HOME=/opt/jdk1.8.0_201"}
- {position: EOF, value: "export PATH=$JAVA_HOME/bin:$PATH"}
- name: chmod bin
file: dest=/opt/jdk1.8.0_201/bin mode=0755 recurse=yes
- name: modify own
shell: chown -R root:root /opt/jdk1.8.0_201
- name: enforce env
shell: source /etc/profile
ansible自动化安装-jdk.yml
最新推荐文章于 2024-01-31 15:22:11 发布