Use Ansible to publish Tomcat service in CentOS 7

Source: Internet
Author: User

Use Ansible to publish Tomcat service in CentOS 7
1. About ansible

Ansible is an Open Server Deployment Tool for Python.
Using yum for configuration is very simple and easy to learn.

2. Install

Http://docs.ansible.com/ansible/intro_installation.html
Refer to the official website and run yum install on CentOS 7.

 sudo yum install ansible
3. Create tomcat and deploy yml

The ansible module has many super Conveniences:
Http://docs.ansible.com/ansible/list_of_all_modules.html
Tomcat directly deletes all the folders in webapps during deployment.
Deploy the tool directly to the webapps/ROOT folder during deployment.
Because webapps contain tomcat admin management and some demos, they are useless, and there are security risks. They can be deleted directly.
Edit admin. yml, where tomcat-admin must be configured in hosts.

-Name: install tomcat admin hosts: tomcat-admin sudo: True vars: war_file:/local-data-dir/admin. war # local file atat_root:/remote-data-dir/tomcat/webapps/ROOT # deployed remote ROOT directory tasks:-name: stop tomcat. action: shell {tomcat_root }}/.. /.. /bin/catalina. sh stop-force-name: rm ROOT. file: state: absent dest: "{tomcat_root}"-name: mkdir ROOT. file: state: directory dest: "{tomcat_root}" owner: root group: root mode: 755-name: unzip war. unarchive: src: "{war_file}" dest: "{tomcat_root}" copy: yes-name: start tomcat. action: shell {tomcat_root }}/.. /.. /bin/catalina. sh start

Five Commands are used to solve the problem of tomcat going online.
1. action: shell stops tomcat because the tomcat directory is directly set to the root directory. A././bin is added.
2. Delete the ROOT folder and use file: state: absent to prevent file Deletion errors.
3. Use the unarchive command, copy: yes to directly copy the local file to a remote location, and decompress the file and delete the file. Several repeated operations are saved. Step by step.
Refer:
Http://docs.ansible.com/ansible/unarchive_module.html

Run ansible-playbook admin. yml to deploy the application. Very simple.

4. Summary

Ansible uses yml, which is very simple to learn.
I hate writing shell, and I use python to deploy some duplicate code.
Debugging is also very troublesome during deployment. ansible is very good, and debugging is easy to add-debug: labels.

Use Ansible to efficiently deliver Docker containers

Batch manage remote servers using Ansible

Ansible installation configuration and simple use

Install and use the automation tool Ansible in CentOS 7

Functions and usage of Ansible and Docker

Ansible batch build LAMP Environment

Ansible: a configuration management and IT automation tool

Ansible details: click here
Ansible: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.