Running ansible role on a host from foreman UI

Hello,
I have ansible installed on my foreman host. I was able to run playbook
from command line and view the reports in foreman without errors. But I am
not able to trigger the role run from foreman UI.

cat /etc/ansible/roles/ntp/tasks/main.yml

··· ---
  • name: Install ntp

    yum: name=ntp state=present

I had associated this role with my localhost and tried to run the role from
Web UI -> Hosts -> Select Host -> Click Play Ansible Roles button.

I was watching the logs and it looks like the role run is triggered in the
background. But the call is not finished (ntp package not installed on my
host) and I don’t see an ansible report posted to foreman too. Any idea of
what is going wrong here?

tail -f /var/log/foreman/*.log

2016-08-16 16:36:51 [app] [I] Performing ForemanAnsible::RunPlaybookJob
from Inline(ansible) with arguments:
"/tmp/foreman-ansible-myhost-roles20160816-1467-1dpx0mq",
"/tmp/foreman-70f95183-725c-4713-95a5-da25269d1425-inventory20160816-1467-kcz14e"

2016-08-16 16:36:51 [foreman_ansible] [I] PID for playbook run for
/tmp/foreman-ansible-myhost-roles20160816-1467-1dpx0mq
/tmp/foreman-70f95183-725c-4713-95a5-da25269d1425-inventory20160816-1467-kcz14e:
3148

2016-08-16 16:36:51 [app] [I] Performed ForemanAnsible::RunPlaybookJob from
Inline(ansible) in 2.88ms

2016-08-16 16:36:51 [app] [I] Enqueued ForemanAnsible::RunPlaybookJob (Job
ID: 27984974-0306-4f0c-bd03-6dd8bc9b714a) to Inline(ansible) with
arguments: “/tmp/foreman-ansible-myhost-roles20160816-1467-1dpx0mq”,
"/tmp/foreman-70f95183-725c-4713-95a5-da25269d1425-inventory20160816-1467-kcz14e"

2016-08-16 16:36:51 [app] [I] Redirected to https://myhost/hosts/myhost

2016-08-16 16:36:51 [app] [I] Completed 302 Found in 19ms (ActiveRecord:
1.9ms)

2016-08-16 16:36:51 [app] [I] Started GET “/hosts/myhost” for 10.10.52.24
at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#show as HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Rendered hosts/_metrics.html.erb (0.2ms)

2016-08-16 16:36:51 [app] [I] Rendered hosts/show.html.erb within
layouts/application (17.5ms)

2016-08-16 16:36:51 [app] [I] Rendered
layouts/_application_content.html.erb (0.2ms)

2016-08-16 16:36:51 [app] [I] Rendered home/_user_dropdown.html.erb (1.4ms)

2016-08-16 16:36:51 [app] [I] Read fragment views/tabs_and_title_records-3
(0.1ms)

2016-08-16 16:36:51 [app] [I] Rendered home/_topbar.html.erb (4.3ms)

2016-08-16 16:36:51 [app] [I] Rendered layouts/base.html.erb (5.0ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 47ms (Views: 20.9ms |
ActiveRecord: 3.8ms)

2016-08-16 16:36:51 [app] [I] Started GET “/hosts/myhost/overview” for
10.10.52.24 at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#overview as HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Started GET “/hosts/myhost/nics” for
10.10.52.24 at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#nics as HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Rendered hosts/_nics.html.erb (6.1ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 14ms (Views: 7.4ms |
ActiveRecord: 1.2ms)

2016-08-16 16:36:51 [app] [I] Rendered hosts/_overview.html.erb (12.0ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 18ms (Views: 11.2ms |
ActiveRecord: 2.0ms)

2016-08-16 16:36:51 [app] [I] Started GET "/hosts/myhost/runtime?range=7"
for 10.10.52.24 at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#runtime as HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“range”=>“7”, “id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Started GET "/hosts/myhost/resources?range=7"
for 10.10.52.24 at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#resources as
HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“range”=>“7”, “id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Rendered hosts/_resources.html.erb (33.9ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 40ms (Views: 33.0ms |
ActiveRecord: 1.9ms)

2016-08-16 16:36:51 [app] [I] Rendered hosts/_runtime.html.erb (302.4ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 309ms (Views: 301.5ms |
ActiveRecord: 2.1ms)

Suresh Thirugnanasambandan RHCSA

irc: sthirugn

> Hello,
> I have ansible installed on my foreman host. I was able to run playbook
> from command line and view the reports in foreman without errors. But I am
> not able to trigger the role run from foreman UI.
>
> # cat /etc/ansible/roles/ntp/tasks/main.yml
>
> —
>
> - name: Install ntp
>
> yum: name=ntp state=present
>
>
> I had associated this role with my localhost and tried to run the role from
> Web UI -> Hosts -> Select Host -> Click Play Ansible Roles button.
>
> I was watching the logs and it looks like the role run is triggered in the
> background. But the call is not finished (ntp package not installed on my
> host) and I don't see an ansible report posted to foreman too. Any idea of
> what is going wrong here?

Hi, from the looks of that log, it ran but never returned anything. It's
quite possible that if you're running this as the foreman user (Foreman
runs as user 'foreman') but that user doesn't have the callback plugin
installed, you won't get any reports.

What's the content of
/tmp/foreman-ansible-myhost-roles20160816-1467-1dpx0mq and
/tmp/foreman-70f95183-725c-4713-95a5-da25269d1425-inventory20160816-1467-kcz14e
?

Notice you can follow what happened at the PID 3148 , so 'tail -f
/proc/3148/fd/1', or 'reptyr 3148' might give you more info about what
happened

··· On 08/16, sureshkumar thirugnanasambandan wrote:

tail -f /var/log/foreman/*.log

2016-08-16 16:36:51 [app] [I] Performing ForemanAnsible::RunPlaybookJob
from Inline(ansible) with arguments:
“/tmp/foreman-ansible-myhost-roles20160816-1467-1dpx0mq”,
“/tmp/foreman-70f95183-725c-4713-95a5-da25269d1425-inventory20160816-1467-kcz14e”

2016-08-16 16:36:51 [foreman_ansible] [I] PID for playbook run for
/tmp/foreman-ansible-myhost-roles20160816-1467-1dpx0mq
/tmp/foreman-70f95183-725c-4713-95a5-da25269d1425-inventory20160816-1467-kcz14e:
3148

2016-08-16 16:36:51 [app] [I] Performed ForemanAnsible::RunPlaybookJob from
Inline(ansible) in 2.88ms

2016-08-16 16:36:51 [app] [I] Enqueued ForemanAnsible::RunPlaybookJob (Job
ID: 27984974-0306-4f0c-bd03-6dd8bc9b714a) to Inline(ansible) with
arguments: “/tmp/foreman-ansible-myhost-roles20160816-1467-1dpx0mq”,
“/tmp/foreman-70f95183-725c-4713-95a5-da25269d1425-inventory20160816-1467-kcz14e”

2016-08-16 16:36:51 [app] [I] Redirected to https://myhost/hosts/myhost

2016-08-16 16:36:51 [app] [I] Completed 302 Found in 19ms (ActiveRecord:
1.9ms)

2016-08-16 16:36:51 [app] [I] Started GET “/hosts/myhost” for 10.10.52.24
at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#show as HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Rendered hosts/_metrics.html.erb (0.2ms)

2016-08-16 16:36:51 [app] [I] Rendered hosts/show.html.erb within
layouts/application (17.5ms)

2016-08-16 16:36:51 [app] [I] Rendered
layouts/_application_content.html.erb (0.2ms)

2016-08-16 16:36:51 [app] [I] Rendered home/_user_dropdown.html.erb (1.4ms)

2016-08-16 16:36:51 [app] [I] Read fragment views/tabs_and_title_records-3
(0.1ms)

2016-08-16 16:36:51 [app] [I] Rendered home/_topbar.html.erb (4.3ms)

2016-08-16 16:36:51 [app] [I] Rendered layouts/base.html.erb (5.0ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 47ms (Views: 20.9ms |
ActiveRecord: 3.8ms)

2016-08-16 16:36:51 [app] [I] Started GET “/hosts/myhost/overview” for
10.10.52.24 at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#overview as HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Started GET “/hosts/myhost/nics” for
10.10.52.24 at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#nics as HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Rendered hosts/_nics.html.erb (6.1ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 14ms (Views: 7.4ms |
ActiveRecord: 1.2ms)

2016-08-16 16:36:51 [app] [I] Rendered hosts/_overview.html.erb (12.0ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 18ms (Views: 11.2ms |
ActiveRecord: 2.0ms)

2016-08-16 16:36:51 [app] [I] Started GET “/hosts/myhost/runtime?range=7”
for 10.10.52.24 at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#runtime as HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“range”=>“7”, “id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Started GET “/hosts/myhost/resources?range=7”
for 10.10.52.24 at 2016-08-16 16:36:51 -0400

2016-08-16 16:36:51 [app] [I] Processing by HostsController#resources as
HTML

2016-08-16 16:36:51 [app] [I] Parameters: {“range”=>“7”, “id”=>“myhost”}

2016-08-16 16:36:51 [app] [I] Rendered hosts/_resources.html.erb (33.9ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 40ms (Views: 33.0ms |
ActiveRecord: 1.9ms)

2016-08-16 16:36:51 [app] [I] Rendered hosts/_runtime.html.erb (302.4ms)

2016-08-16 16:36:51 [app] [I] Completed 200 OK in 309ms (Views: 301.5ms |
ActiveRecord: 2.1ms)

Suresh Thirugnanasambandan RHCSA

irc: sthirugn


You received this message because you are subscribed to the Google Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Daniel Lobato Garcia

@dLobatog

GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30
Keybase: elobato (Daniel Lobato Garcia) | Keybase