ansible-playbook部署tomcat
1、准备3台机器(一台centos7,两台centos6)
10.0.0.171
10.0.0.61
10.0.0.62
2、centos7:
3、yum -y install ansible
4、ssh-key
5、ssh-copy-id [email protected]
扫描二维码关注公众号,回复:
9923548 查看本文章
6、ssh-copy-id [email protected]
7、vim /etc/ansible/hosts
8、ansible webserver -m ping
9、vim tomcat.yml
---
- hosts: webservers
tasks:
- name: "推送jdk"
copy: src=jdk-8u131-linux-x64_.rpm dest=/root/
- name: "安装jdk"
shell: cd /root/ && rpm -ivh jdk-8u131-linux-x64_.rpm || /bin/true
- name: "推送tomcat"
unarchive: src=apache-tomcat-8.5.35.tar.gz dest=/opt/
- name: "启动tomcat"
shell: nohup /opt/apache-tomcat-8.5.35/bin/catalina.sh run &
10、ansible-playbook tomcat.yml
11、ansible webservers -m shell -a 'ss -ntl | grep 8080’
12、ansible webservers -m shell -a 'name=iptables state=stopped’