Ansible After completion of the deployment will not start Tomcat has been found through automation, which is the environment variable you want to add to the file system and /root/.bashrc /root/.bash_profile.
Ansible features:
- ansible-based implementation, there Paramiko, PyYAML, JinJia2 main module
- Use SSH host link, simple to deploy
- You can use custom modules, you can use other modules written language, based module can complete various tasks.
1, first, three machines
ansible machine: 192.168.52.34
Destination Host: 192.168.52.35
Destination Host: 192.168.52.36
2, turn off the firewall
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
3, configuration-free dense Login
4, installation ansible
yum -y install ansible
5, add the target host ansible profile
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
6, check whether the destination host in communication with ansible
7, upload tomcat, jdk
[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 ~]#
8, write tomcat.yml
[Root @ localhost ~] # vim tomcat.yml
9, check tomcat.yml
[root @ localhost ~] # ansible-PlayBook --syntax the Check-tomcat.yml
# This is the meaning of the warning can be ignored
[WARNING]: Could not match supplied host pattern, ignoring: tomcat
playbook: tomcat.yml
[root@localhost ~]#
10, execution tomcat.yml
[root@localhost ~]# ansible-playbook tomcat.yml
11, complete