Ansible Study Notes (1)

Source: Internet
Author: User

I recently learned how to use ansible to prepare for large-scale application deployment in the future. This is easier than puppet and saltstack I have used before. There is no client and no additional configuration is required, it is said that the popularity in foreign countries has exceeded saltstack.

Let's start with sporadic records.


Make sure the service is running

tasks:  - name: make sure apache is running    service: name=httpd state=running

Variables can be used to write the vhost configuration file of the Web server.

Tasks:
-Name: create a virtual host file for {vhost }}
Template: src = somefile. J2 DEST =/etc/httpd/CONF. d/{vhost }}


The following two examples are provided in combination. Tasks in worker y are called handlers. They are defined separately. Worker y specifies the name of handlers, and handlers lists tasks of various entries.
-Name: Template configuration file
Template: src = template. J2 DEST =/etc/Foo. conf
Notify:
-Restart memcached
-Restart Apache

Handlers:
-Name: restart memcached
Service: Name = memcached state = restarted
-Name: restart Apache
Service: Name = Apache state = restarted

This article is from the breeze blog, please be sure to keep this source http://387249.blog.51cto.com/377249/1565151

Ansible Study Notes (1)

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.