码迷,mamicode.com
首页 > 编程语言 > 详细

ansible roles实践——安装java

时间:2018-03-12 21:02:55      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:6.2   use   roles   bsp   profile   pre   yml   usr   dt.jar   

1、tasks/main.yml

---
- name: mkdir necessary directory
file: path=/usr/java/ state=directory mode=0755
- name: unzip jdk
unarchive: src={{ jdk_package_name }} dest=/usr/java/
- name: set env
lineinfile: dest={{ env_file }} insertafter={{ item.position }} line={{ item.value }} state=present
with_items:
- {position: EOF,value: "\n"}
- {position: EOF,value: "export JAVA_HOME=/usr/java/{{ jdk_version }}"}
- {position: EOF,value: "export PATH=$JAVA_HOME/bin/:$PATH"}
- {position: EOF,value: "export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar"}
- name: enforce env
 shell: source {{ env_file }}

2、vars/main.yml

---
jdk_package_name: jdk-8u121-linux-x64.tar.gz
env_file: /etc/profile
jdk_version: jdk1.8.0_121

3、入口jdk.yml

---
- hosts: 172.16.2.241
  remote_user: root
  roles:
   - jdk

ansible roles实践——安装java

标签:6.2   use   roles   bsp   profile   pre   yml   usr   dt.jar   

原文地址:https://www.cnblogs.com/fanren224/p/8550977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!