ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。
ansible机器:192.168.52.34
目标主机:192.168.52.35
目标主机:192.168.52.36
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
yum -y install ansible
vim /etc/ansible/hosts
## [webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110
[tomcat]
192.168.52.35
192.168.52.36
# If you have multiple hosts following a pattern you can specify
# them like this:
## www[001:006].example.com
[root@localhost ~]# rz
[root@localhost ~]# rz
[root@localhost ~]# ls
anaconda-ks.cfg apache-tomcat-8.5.35.tar.gz jdk-8u131-linux-x64_.rpm original-ks.cfg
[root@localhost ~]#
[root@localhost ~]# vim tomcat.yml
---
- hosts: tomcat
tasks:
- name: 关闭防火墙
shell: systemctl stop firewalld
- name: 关闭selinux
shell: setenforce 0
- name: 推送jdk Java环境
copy: src=jdk-8u131-linux-x64_.rpm dest=/root
- name: 创建文件夹
file: path=/opt/tomcat state=directory
- name: 推送tomcat的压缩包
unarchive: src=apache-tomcat-8.5.35.tar.gz dest=/opt/tomcat
- name: 安装jdk
yum: name=jdk-8u131-linux-x64_.rpm state=installed
- name: 启动tomcat
shell: nohup /opt/tomcat/apache-tomcat-8.5.35/bin/startup.sh
[root@localhost ~]# ansible-playbook --syntax-check tomcat.yml
#这个是警告的意思可以忽略
[WARNING]: Could not match supplied host pattern, ignoring: tomcat
playbook: tomcat.yml
[root@localhost ~]#
[root@localhost ~]# ansible-playbook tomcat.yml
网站题目:通过ansible部署Tomcat
网站路径:http://www.shufengxianlan.com/qtweb/news24/368624.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联