如何在 Ubuntu + Apache2.4 + mod_wsgi 上为 Ansible 配置 ARA?



我正在尝试在 Ubuntu 16.04 上安装 ARA (https://github.com/openstack/ara) 来监控我的 Ansible 剧本执行。

我仔细遵循文档(http://ara.readthedocs.io/en/latest/webserver.html#debian-ubuntu),但每次测试时,我都会被重定向到 http://ara.home.lab/about

这是我的配置文件:

Apache Vhost:

cat /etc/apache2/sites-available/ara.conf
<VirtualHost *:80>
# Replace ServerName by your hostname
ServerName ara.home.lab
ErrorLog /var/log/apache2/ara-error.log
LogLevel warn
CustomLog /var/log/apache2/ara-access.log combined
WSGIDaemonProcess ara user=www-data group=www-data processes=4 threads=1
WSGIScriptAlias / /var/www/ara/ara-wsgi
SetEnv ANSIBLE_CONFIG /var/www/ara/ansible.cfg
<Directory /var/www/ara>
WSGIProcessGroup ara
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost>

Ansible 配置文件:

cat /var/www/ara/ansible.cfg
[defaults]
# This directory is required to store temporary files for Ansible and ARA
local_tmp = /var/www/ara/.ansible/tmp
[ara]
# This will default the database and logs location to be inside that directory.
dir = /var/www/ara/.ara

虚拟主机目录:

$ pwd
/var/www/ara
$ ls -la
total 24
drwxr-xr-x 4 www-data www-data 4096 Mar 12 00:15 .
drwxr-xr-x 7 root     root     4096 Mar 11 23:59 ..
drwxrwx--- 3 www-data www-data 4096 Oct 27 17:00 .ansible
-rw-r--r-- 1 www-data www-data  234 Oct 27 16:57 ansible.cfg
drwx------ 2 www-data www-data 4096 Mar 12 00:15 .ara
-rwxr-xr-x 1 www-data www-data 1804 Mar 11 01:08 ara-wsgi

到目前为止,我无法从应用程序中找到任何告诉我错误的日志。

你能帮我吗?

您的配置看起来不错,但是您缺少告诉Ansible需要加载ARA回调插件以及它所在的位置。

要查找 ARA 的位置,您可以运行以下命令,无论您运行的是 python2 还是 python3,该命令都有效:

$ python -c "import os,ara; print(os.path.dirname(ara.__file__))"

如果 ARA 安装在虚拟环境中,则需要在运行该命令之前获取并激活它。

如果它有效,它应该打印如下内容:

# The path for your ARA package might be different than this
/usr/local/lib/python2.7/dist-packages/ara

要启用 ARA 作为 Ansible 回调插件,请将此路径添加到 ansible.cfg 中的callback_plugins配置中:

[defaults]
# This directory is required to store temporary files for Ansible and ARA
local_tmp = /var/www/ara/.ansible/tmp
callback_plugins = /usr/local/lib/python2.7/dist-packages/ara/plugins/callbacks
[ara]
# This will default the database and logs location to be inside that directory.
dir = /var/www/ara/.ara

您可以通过查看/var/www/ara/.ara目录来判断这是否有效 - 您将在应用程序引导自身时自动创建一个ansible.sqlite文件。

这是您的用户Apache 需要读写访问权限的数据库。这是一个留给读者的练习,因为它是关于文件系统权限的——一些用户创建了一个包含$USERwww-data的公共组。

最新更新