使用 ARA 分析 Ansible 运行
Ansible

> 
> Ansible 运行分析工具（ARA）与 Ansible 无缝集成，可以简单便捷的找到你所需数据的方法。
> 
> 
> 


![](/data/attachment/album/201806/12/110004oyw5z6m5ocro5ni5.png)


[Ansible](https://www.ansible.com/) 是一个多功能平台，它已经成为管理服务器和服务器配置的流行平台。如今，Ansible 大量用于通过持续集成 （CI） 进行部署和测试。


在自动化持续集成的世界中，每天都有数百个甚至数千个作业运行测试、构建、编译、部署等等，这并不罕见。


### Ansible 运行分析 （ARA） 工具


Ansible 运行生成大量控制台数据，在 CI 的环境下跟上大量的 Ansible 输出是具有挑战性的。Ansible Run Analysis（ARA） 工具使此详细输出可读并且使作业状态和调试信息更有代表性。ARA 组织了记录的<ruby> 剧本 <rt>  playbook </rt></ruby>数据，以便你尽可能快速和容易地搜索并找到你感兴趣的内容。


请注意，ARA 不会运行你的<ruby> 剧本 <rt>  playbook </rt></ruby>。相反，无论在哪它都它作为回调插件与 Ansible 集成。回调插件可以在响应事件时向 Ansible 添加新行为。它可以根据 Ansible 事件执行自定义操作，例如在主机开始执行或任务完成时执行。


与 [AWX](https://www.ansible.com/products/awx-project) 和 [Tower](https://www.ansible.com/products/tower) 相比，它们是控制整个工作流程的工具，具有仓库管理、<ruby> 剧本 <rt>  playbook </rt></ruby>执行、编辑功能等功能，ARA 的范围相对较窄：记录数据并提供直观的界面。这是一个相对简单的程序，易于安装和配置。


#### 安装


在系统上安装 ARA 有两种方法：


* 使用托管在 [GitHub 帐户](https://github.com/AjinkyaBapat/Ansible-Run-Analyser) 上的 Ansible 角色。克隆仓库并：



```
ansible-playbook Playbook.yml

```

如果剧本执行成功，你将看到：



```
TASK [ara : Display ara UI URL] ************************
   ok: [localhost] =&gt; {}
   "msg": "Access playbook records at http://YOUR_IP:9191"

```

注意：它从 Ansible 收集的 `ansible_default_ipv4` fact 中选择 IP 地址。如果没有收集这些 fact，请用 `roles/ara/tasks/` 文件夹中 `main.yml` 文件中的 IP 替换它。
* ARA 是一个在 [GitHub](https://github.com/dmsimard/ara) 上以 Apache v2 许可证授权的开源项目。安装说明在快速入门章节。[文档](http://ara.readthedocs.io/en/latest/)和 [FAQ](http://ara.readthedocs.io/en/latest/faq.html) 可在 [readthedocs.io](http://ara.readthedocs.io/en/latest/) 上找到。


#### ARA 能做些什么？


下图显示了从浏览器启动 ARA 登录页面：


![ara landing page](/data/attachment/album/201806/12/110005y0gqw0rmlhpfr17l.png "ara landing page")


*ARA 登录页面*


它提供了每个主机或每个 playbook 的任务结果摘要：


![task summaries](/data/attachment/album/201806/12/110006q7cgzquahqqziliq.png "task summaries")


*ARA 显示任务摘要*


它允许你通过剧本，play，主机、任务或状态来过滤任务结果：


![playbook runs filtered by hosts](/data/attachment/album/201806/12/110007g4xbva4464z1e6i1.png "playbook runs filtered by hosts")


*通过主机过滤剧本运行*


借助 ARA，你可以在摘要视图中轻松查看你感兴趣的结果，无论是特定的主机还是特定的任务：


![summary of each task](/data/attachment/album/201806/12/110008ce8qc2zeq2ffxecv.png "summary of each task")


*每项任务的详细摘要*


ARA 支持在同一数据库中记录和查看多个运行。


![show gathered facts](/data/attachment/album/201806/12/110009iarssftrsoarwt1a.png "show gathered facts")


*显示收集的 fact*


#### 总结


ARA 是一个已经帮助我从 Ansible 运行日志和输出中了解更多的有用资源。我强烈推荐给所有的 Ansible 使用者。


请随意分享，并请在评论中告诉我你使用 ARA 的经历。


[参见我们的相关文章，[成功使用 Ansible 的秘诀](/article/18/2/tips-success-when-getting-started-ansible)]。




---


via: <https://opensource.com/article/18/5/analyzing-ansible-runs-using-ara>


作者：[Ajinkya Bapat](https://opensource.com/users/iamajinkya) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
[Ansible](https://www.ansible.com/) is a versatile platform that has become popular for managing servers and server configurations. Today, Ansible is used heavily to deploy and test through continuous integration (CI).

In the world of automated continuous integration, it’s not uncommon to have hundreds, if not thousands, of jobs running every day for testing, building, compiling, deploying, and more.

## The Ansible Run Analysis (ARA) tool

Ansible runs generate a large amount of console data, and keeping up with high volumes of Ansible output in the context of CI is challenging. The Ansible Run Analysis (ARA) tool makes this verbose output readable and more representative of the job status and debug information. ARA organizes recorded playbook data so you can search and find what you’re interested in as quickly and as easily as possible.


Note that ARA doesn't run your playbooks for you; rather, it integrates with Ansible as a callback plugin wherever it is. A callback plugin enables adding new behaviors to Ansible when responding to events. It can perform custom actions in response to Ansible events such as a play starting or a task completing on a host.

Compared to [AWX](https://www.ansible.com/products/awx-project) and [Tower](https://www.ansible.com/products/tower), which are tools that control the entire workflow, with features like inventory management, playbook execution, editing features, and more, the scope of ARA is comparatively narrow: It records data and provides an intuitive interface. It is a relatively simple application that is easy to install and configure.

### Installation

There are two ways to install ARA on your system:

- Using the Ansible role hosted on your
[GitHub account](https://github.com/AjinkyaBapat/Ansible-Run-Analyser). Clone the repo and do:

```
````ansible-playbook Playbook.yml`


If the playbook run is successful, you will get:

```
``````
TASK [ara : Display ara UI URL] ************************
ok: [localhost] => {}
"msg": "Access playbook records at http://YOUR_IP:9191"
```


Note: It picks the IP address from `ansible_default_ipv4`

fact gathered by Ansible. If there is no such fact gathered, replace it with your IP in `main.yml`

file in the `roles/ara/tasks/`

folder.

- ARA is an open source project available on
[GitHub](https://github.com/dmsimard/ara)under the Apache v2 license. Installation instructions are in the Quickstart chapter. The[documentation](http://ara.readthedocs.io/en/latest/)and[FAQs](http://ara.readthedocs.io/en/latest/faq.html)are available on[readthedocs.io](http://ara.readthedocs.io/en/latest/).

### What can ARA do?

The image below shows the ARA landing page launched from the browser:

![ara landing page ara landing page](https://opensource.com/sites/default/files/images/life-uploads/ara_landing_page.png)

It provides summaries of task results per host or per playbook:

![task summaries task summaries](https://opensource.com/sites/default/files/images/life-uploads/task_summaries.png)

It allows you to filter task results by playbook, play, host, task, or status:

![playbook runs filtered by hosts playbook runs filtered by hosts](https://opensource.com/sites/default/files/images/life-uploads/playbook_filtered_by_hosts.png)

With ARA, you can easily drill down from the summary view to find the results you’re interested in, whether it’s a particular host or a specific task:

![summary of each task summary of each task](https://opensource.com/sites/default/files/images/life-uploads/summary_of_each_task.png)

ARA supports recording and viewing multiple runs in the same database.

![show gathered facts show gathered facts](https://opensource.com/sites/default/files/images/life-uploads/showing_gathered_facts.png)

### Wrapping up

ARA is a useful resource that has helped me get more out of Ansible run logs and outputs. I highly recommend it to all Ansible ninjas out there.

Feel free to share this, and please let me know about your experience using ARA in the comments.

**[See our related story, Tips for success when getting started with Ansible.]**

## Comments are closed.