官术网_书友最值得收藏!

Getting introduced to Ansible

Ansible is a simple, flexible, and extremely powerful tool that gives you the ability to automate common infrastructure tasks, run ad hoc commands, and deploy multitier applications spanning multiple machines. Even though you can use Ansible to launch commands on a number of hosts in parallel, the real power lies in managing those using playbooks.

As systems engineer, infrastructure that we typically need to automate contains complex multitier applications. Each of which represents a class of servers, for example, load balancers, web servers, database servers, caching applications, and middleware queues. Since many of these applications have to work in tandem to provide a service, there is topology involved as well. For example, a load balancer would connect to web servers, which in turn read/write to a database and connect to the caching server to fetch in-memory objects. Most of the time, when we launch such application stacks, we need to configure these components in a very specific order.

Here is an example of a very common three-tier web application running a load balancer, a web server, and a database backend:

Getting introduced to Ansible

Ansible lets you translate this diagram into a blueprint, which defines your infrastructure policies. The format used to specify such policies is what playbooks are.

Example policies and the sequence in which those are to be applied is shown in the following steps:

  1. Install, configure, and start the MySQL service on the database servers.
  2. Install and configure the web servers that run Nginx with PHP bindings.
  3. Deploy a Wordpress application on the web servers and add respective configurations to Nginx.
  4. Start the Nginx service on all web servers after deploying Wordpress. Finally, install, configure, and start the haproxy service on the load balancer hosts. Update haproxy configurations with the hostnames of all the web servers created earlier.

The following is a sample playbook that translates the infrastructure blueprint into policies enforceable by Ansible:

Getting introduced to Ansible
主站蜘蛛池模板: 潞西市| 北流市| 新龙县| 湖南省| 东兰县| 饶平县| 布拖县| 安仁县| 瓦房店市| 漾濞| 嫩江县| 通道| 凤台县| 永寿县| 淮北市| 余姚市| 景洪市| 平南县| 佛冈县| 广河县| 科技| 云林县| 福安市| 贵州省| 横山县| 原平市| 镇坪县| 雷波县| 南漳县| 永泰县| 南郑县| 福建省| 栾城县| 镇雄县| 青冈县| 县级市| 盐城市| 黔江区| 石台县| 重庆市| 西昌市|