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)