1

I can generate report when I run the same job via command line simply by following these steps:

% sudo su jenkins
% export ANSIBLE_CALLBACK_PLUGINS="/usr/lib/python2.7/site-packages/ara/plugins/callbacks"
% /bin/ansible-playbook -v -i /etc/ansible/my-inventory ./test-job.yaml`

However I am having some problems in generating ARA report while executing the same job via Jenkins. I have done the following:

  1. Inside $JENKINS_HOME/.bashrc:

    export ANSIBLE_CALLBACK_PLUGINS="/usr/lib/python2.7/site-packages/ara/plugins/callbacks" `

  2. Defined the following environment variable via: Jenkins UI -> Manage Jenkins -> Configure System:

    Name: ANSIBLE_CALLBACK_PLUGINS Value: /usr/lib/python2.7/site-packages/ara/plugins/callbacks

  3. Inside my Ansible Job -> Execute shell, I have specified the following:

    export ANSIBLE_CALLBACK_PLUGINS="/usr/lib/python2.7/site-packages/ara/plugins/callbacks"

    /bin/ansible-playbook -v -i /etc/ansible/my-inventory ./test-job.yaml

Here is the content of .ansible.cfg:

[default]
# the following lines added for ara callback_plugins configuration is required for the ARA callback
callback_plugins = /usr/lib/python2.7/site-packages/ara/plugins/callbacks

# action_plugins and library configuration is required for the ara_record and ara_read modules
action_plugins = /usr/lib/python2.7/site-packages/ara/plugins/actions
library = /usr/lib/python2.7/site-packages/ara/plugins/modules

[ara]
ARA_HOST = 0.0.0.0
ARA_PORT = 8443
askb
  • 6,501
  • 30
  • 43
Yagna Pant
  • 33
  • 5

2 Answers2

2

There are different ways to run ARA with Jenkins.

The callback sends data to a database and the web application reads from that database.

By default this database is located at ~/.ara/ansible.sqlite. This might be /var/lib/jenkins/.ara/ansible.sqlite if you're executing your ansible-playbook command from the jenkins user, for example.

Ideally, you want to want to have one database and one report per job so that everything is self contained -- it scales better than one large monolithic database right now.

You can customize the location of your database by doing something like this:

export ARA_DATABASE="sqlite:///$WORKSPACE/$JOB_NAME.sqlite"

All the data is self-contained in that database. You could download it and browse it locally if you'd like.

You could also generate a static HTML report. While we don't use Jenkins, this is exactly what we do in the OpenStack community. For any CI job, we upload logs to a server with an attached "ara" report directory:

log directory

ara report

The supported way moving forward is likely to be implemented around a WSGI middleware to allow you to load "arbitrary" databases which auto-scales better. You can read more about this here: https://ara.readthedocs.io/en/latest/advanced.html#serving-ara-sqlite-databases-over-http

If you want to run the web application on your Jenkins server, you can do that too. The only thing to remember is that your callback and your web application both have access to the database. You can try the embedded web server easily with the ara-manage runserver command.

Hope this helps!

BPDESILVA
  • 2,040
  • 5
  • 15
  • 35
0

When I refreshed my browser earlier this morning, I was able to see reporting on all of my jobs that were executed over night. These nightly jobs did NOT have environment variable set (item 3) above.

export ANSIBLE_CALLBACK_PLUGINS="/usr/lib/python2.7/site-packages/ara/plugins/callbacks"

So looks like by following items 1 and 2 above I was able to run ansible tasks via Jenkins job and view report from ARA.

Yagna Pant
  • 33
  • 5