ansible安装tomcat一个很low的写法,后面再更新高级的写法
注:下面with_items显示不正常,具体请看图片~
---
- hosts: all
remote_user: root
tasks:
- name: "复制jdk文件到目标服务器"
copy:
src=\‘#\‘" /{{ item.src }}
dest: "{{ item.dest }}"
with_items:
- src=\‘#\‘" /usr/local/src/
- src=\‘#\‘" /usr/local/src/
- src=\‘#\‘" /etc/profile.d/
- name: "安装jdk"
yum:
name: /usr/local/src/jdk-8u111-linux-x64.rpm
state: present
- name: "配置java环境变量"
shell: "source /etc/profile"
- name: "安装tomcat"
unarchive:
src=\‘#\‘" /usr/local/src/apache-tomcat-8.0.30.tar.gz
dest: /usr/local/
copy: no
- name: "为tomcat创建软链接"
file:
src=\‘#\‘" /usr/local/apache-tomcat-8.0.30
dest: /usr/local/tomcat
state: link
- name: "给sh脚本增加执行权限"
shell: ‘find /usr/local/tomcat/bin/ -name "*.sh" | xargs chmod +x‘
- name: "启动tomcat"
shell: ‘nohup /usr/local/tomcat/bin/startup.sh &‘以上playbook经过测试是没有问题的,后面学习后会给上传更严谨的写法~
本文出自 “激情燃烧的岁月” 博客,请务必保留此出处http://liuzhengwei521.blog.51cto.com/4855442/1961566
原文:http://liuzhengwei521.blog.51cto.com/4855442/1961566