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

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
主站蜘蛛池模板: 独山县| 图片| 府谷县| 通许县| 宝坻区| 肥西县| 神农架林区| 奉化市| 肇源县| 集安市| 镇平县| 青阳县| 德州市| 蛟河市| 卢湾区| 西盟| 深圳市| 焦作市| 奈曼旗| 蒲江县| 鄢陵县| 阿克| 宜州市| 肇州县| 日土县| 铜鼓县| 三亚市| 运城市| 新邵县| 门源| 湘阴县| 高陵县| 拜泉县| 白银市| 鸡东县| 黑河市| 云安县| 专栏| 焉耆| 惠州市| 白水县|