Ansible host setup failing to populate hosts in Foreman

Greetings,

I have been unable to add hosts using "ansible -m setup hostname".

I have recently installed Foreman 1.14.3 with the Katello scenario and the
Ansible plugin v 2.2.1.0 using "foreman-installer --scenario=katello
–enable-foreman-plugin-ansible". Everything seems to be working fine
except for no hosts are showing up using Ansible.

I have successfully run a playbook on this host and followed these
instructions: Foreman :: Plugin Manuals

Here are the relevant config changes:

/usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py:

FOREMAN_URL = os.getenv('FOREMAN_URL', "https://localhost")

/etc/ansible/ansible.cfg:
[defaults]
callback_whitelist = foreman

callback_plugins =
/usr/lib/python2.7/site-packages/ansible/plugins/callback

bin_ansible_callbacks = True

The host I'm trying to set up is in trusted_puppetmaster_hosts in Foreman

ignore_puppet_facts_for_provisioning = No

RESULTS:

Running "ansible -m setup hostname" returns no errors, just a lot of system
info to stdout. Here are the foreman production.log entries during the
setup:

2017-04-19 12:53:09 58d05530 [app] [I] Started POST "/api/v2/hosts/facts"
for 10.121.66.130 at 2017-04-19 12:53:09 -0500
2017-04-19 12:53:09 58d05530 [app] [I] Processing by
Api::V2::HostsController#facts as JSON
2017-04-19 12:53:09 58d05530 [app] [I] Parameters:
{"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2",
:host=>{"name"=>"hostname.domain.com"}}
2017-04-19 12:53:09 58d05530 [audit] [I] [hostname.domain.com] deleted 0
(15.0ms)
2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] updated 18
(594.4ms)
2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] added 0
(6.2ms)
2017-04-19 12:53:10 58d05530 [app] [I] Import facts for
'hostname.domain.com' completed. Added: 0, Updated: 18, Deleted 0 facts
2017-04-19 12:53:10 58d05530 [app] [I] Completed 201 Created in 755ms
(Views: 4.0ms | ActiveRecord: 103.9ms)
2017-04-19 12:53:10 c522a2fd [app] [I] Started POST "/api/v2/hosts/facts"
for 10.121.66.130 at 2017-04-19 12:53:10 -0500
2017-04-19 12:53:10 c522a2fd [app] [I] Processing by
Api::V2::HostsController#facts as JSON
2017-04-19 12:53:10 c522a2fd [app] [I] Parameters:
{"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2",
:host=>{"name"=>"hostname.domain.com"}}
2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] deleted 0
(18.9ms)
2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] updated 0
(532.0ms)
2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] added 0
(6.4ms)
2017-04-19 12:53:10 c522a2fd [app] [I] Import facts for
'hostname.domain.com' completed. Added: 0, Updated: 0, Deleted 0 facts
2017-04-19 12:53:10 c522a2fd [app] [I] Completed 201 Created in 687ms
(Views: 8.6ms | ActiveRecord: 94.1ms)

Any advice is greatly appreciated.

Jarret

Sorry I pasted "foreman.py" in the original post. It is
"foreman_callback.py" obtained using the url from the manual. "localhost"
was replaced with the FQDN of my Foreman host, now the modifications are:

FOREMAN_URL = os.getenv('FOREMAN_URL', "https://myforemanhost.domain.com")

Substitute by a real SSL certificate and key if your Foreman uses HTTPS

FOREMAN_SSL_CERT = (os.getenv('FOREMAN_SSL_CERT',
"/etc/foreman/client_cert.pem"),
os.getenv('FOREMAN_SSL_KEY',
"/etc/foreman/client_key.pem"))
FOREMAN_SSL_VERIFY = os.getenv('FOREMAN_SSL_VERIFY', "0")

Yet still no hosts show up in Foreman after running "ansible -m setup
…". Thanks!

··· On Wednesday, April 19, 2017 at 1:57:40 PM UTC-5, J Webb wrote: > > Greetings, > > I have been unable to add hosts using "ansible -m setup hostname". > > I have recently installed Foreman 1.14.3 with the Katello scenario and the > Ansible plugin v 2.2.1.0 using "foreman-installer --scenario=katello > --enable-foreman-plugin-ansible". Everything seems to be working fine > except for no hosts are showing up using Ansible. > > I have successfully run a playbook on this host and followed these > instructions: > https://theforeman.org/plugins/foreman_ansible/1.x/index.html > > Here are the relevant config changes: > > /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py: > > FOREMAN_URL = os.getenv('FOREMAN_URL', "https://localhost") > > /etc/ansible/ansible.cfg: > [defaults] > callback_whitelist = foreman > ... > callback_plugins = > /usr/lib/python2.7/site-packages/ansible/plugins/callback > ... > bin_ansible_callbacks = True > > The host I'm trying to set up is in trusted_puppetmaster_hosts in Foreman > > ignore_puppet_facts_for_provisioning = No > > RESULTS: > > Running "ansible -m setup hostname" returns no errors, just a lot of > system info to stdout. Here are the foreman production.log entries during > the setup: > > 2017-04-19 12:53:09 58d05530 [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:09 -0500 > 2017-04-19 12:53:09 58d05530 [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:09 58d05530 [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:09 58d05530 [audit] [I] [hostname.domain.com] deleted 0 > (15.0ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] updated 18 > (594.4ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] added 0 > (6.2ms) > 2017-04-19 12:53:10 58d05530 [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 18, Deleted 0 facts > 2017-04-19 12:53:10 58d05530 [app] [I] Completed 201 Created in 755ms > (Views: 4.0ms | ActiveRecord: 103.9ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:10 -0500 > 2017-04-19 12:53:10 c522a2fd [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:10 c522a2fd [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] deleted 0 > (18.9ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] updated 0 > (532.0ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] added 0 > (6.4ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 0, Deleted 0 facts > 2017-04-19 12:53:10 c522a2fd [app] [I] Completed 201 Created in 687ms > (Views: 8.6ms | ActiveRecord: 94.1ms) > > Any advice is greatly appreciated. > > Jarret >

I also ran a simple playbook after seeing that solve this issue for
someone, I added the "gather_facts: yes" directive in the yaml file for my
host and still it does not show up in Foreman. However when running this
playbook there are 3 errors now in the production.log:

2017-04-20 22:58:07 5ed25d05 [app] [E] Unprocessable entity ConfigReport
(id: new):
2017-04-20 22:58:07 beef70f9 [app] [E] Unprocessable entity ConfigReport
(id: new):
2017-04-20 22:58:07 3eddb29b [app] [E] Unprocessable entity ConfigReport
(id: new):

Full output of the run is attached. FWIW I am running ansible
2.2.1.0-1.el7 from EPEL which is providing /etc/ansible and
/usr/lib/python2.7/site-
packages/ansible/plugins/callback. Thanks again everyone…

JW

getfacts.production.log (3.87 KB)

··· On Wednesday, April 19, 2017 at 1:57:40 PM UTC-5, J Webb wrote: > > Greetings, > > I have been unable to add hosts using "ansible -m setup hostname". > > I have recently installed Foreman 1.14.3 with the Katello scenario and the > Ansible plugin v 2.2.1.0 using "foreman-installer --scenario=katello > --enable-foreman-plugin-ansible". Everything seems to be working fine > except for no hosts are showing up using Ansible. > > I have successfully run a playbook on this host and followed these > instructions: > https://theforeman.org/plugins/foreman_ansible/1.x/index.html > > Here are the relevant config changes: > > /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py: > > FOREMAN_URL = os.getenv('FOREMAN_URL', "https://localhost") > > /etc/ansible/ansible.cfg: > [defaults] > callback_whitelist = foreman > ... > callback_plugins = > /usr/lib/python2.7/site-packages/ansible/plugins/callback > ... > bin_ansible_callbacks = True > > The host I'm trying to set up is in trusted_puppetmaster_hosts in Foreman > > ignore_puppet_facts_for_provisioning = No > > RESULTS: > > Running "ansible -m setup hostname" returns no errors, just a lot of > system info to stdout. Here are the foreman production.log entries during > the setup: > > 2017-04-19 12:53:09 58d05530 [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:09 -0500 > 2017-04-19 12:53:09 58d05530 [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:09 58d05530 [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:09 58d05530 [audit] [I] [hostname.domain.com] deleted 0 > (15.0ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] updated 18 > (594.4ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] added 0 > (6.2ms) > 2017-04-19 12:53:10 58d05530 [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 18, Deleted 0 facts > 2017-04-19 12:53:10 58d05530 [app] [I] Completed 201 Created in 755ms > (Views: 4.0ms | ActiveRecord: 103.9ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:10 -0500 > 2017-04-19 12:53:10 c522a2fd [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:10 c522a2fd [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] deleted 0 > (18.9ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] updated 0 > (532.0ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] added 0 > (6.4ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 0, Deleted 0 facts > 2017-04-19 12:53:10 c522a2fd [app] [I] Completed 201 Created in 687ms > (Views: 8.6ms | ActiveRecord: 94.1ms) > > Any advice is greatly appreciated. > > Jarret >

I started over with a fresh RHEL7 VM and went through all installation
steps again to make sure there was nothing I missed. Same results.

This time yum picked up ansible-2.3.0.0-3.el7.noarch from EPEL. This
version appears to come with its own callback foreman.py. I have tried
this version and foreman_callback.py both in the location provided by
ansible from EPEL (/usr/lib/python2.7/site-
packages/ansible/plugins/callback/foreman.py) and in a separate directory I
created just to isolate them (yes I updated ansible.cfg whenever I moved
the callback scripts).

It appears that the host is stored in the database (or a file) because i
regularly see this in production.log:

2017-05-02 13:32:34 f6afba3a [app] [I] Started GET
"/node/hostname.domain.com?format=yml" for 10.121.66.130 at 2017-05-02
13:32:34 -0500
2017-05-02 13:32:34 f6afba3a [app] [I] Processing by
HostsController#externalNodes as YML
2017-05-02 13:32:34 f6afba3a [app] [I] Parameters:
{"name"=>"hostname.domain.com"}
2017-05-02 13:32:34 f6afba3a [app] [I] Rendered text template (0.0ms)
2017-05-02 13:32:34 f6afba3a [app] [I] Completed 200 OK in 107ms (Views:
0.7ms | ActiveRecord: 10.0ms)
2017-05-02 13:32:35 76fb48ea [app] [I] Started POST "/api/hosts/facts" for
10.121.66.130 at 2017-05-02 13:32:35 -0500
2017-05-02 13:32:35 76fb48ea [app] [I] Processing by
Api::V2::HostsController#facts as JSON
2017-05-02 13:32:35 76fb48ea [app] [I] Parameters:
{"facts"=>"[FILTERED]", "name"=>"hostname.domain.com",
"certname"=>"hostname.domain.com", "apiv"=>"v2",
:host=>{"certname"=>"hostname.domain.com", "name"=>"hostname.domain.com"}}
2017-05-02 13:32:35 76fb48ea [audit] [I] [hostname.domain.com] deleted 0
(8.1ms)
2017-05-02 13:32:35 76fb48ea [audit] [I] [hostname.domain.com] updated 15
(437.0ms)
2017-05-02 13:32:35 76fb48ea [audit] [I] [hostname.domain.com] added 0
(2.9ms)
2017-05-02 13:32:35 76fb48ea [app] [I] Import facts for
'hostname.domain.com' completed. Added: 0, Updated: 15, Deleted 0 facts
2017-05-02 13:32:35 76fb48ea [app] [I] Completed 201 Created in 534ms
(Views: 3.6ms | ActiveRecord: 69.7ms)
2017-05-02 13:32:35 7f153fdf [app] [I] Started GET
"/node/hostname.domain.com?format=yml" for 10.121.66.130 at 2017-05-02
13:32:35 -0500
2017-05-02 13:32:35 7f153fdf [app] [I] Processing by
HostsController#externalNodes as YML
2017-05-02 13:32:35 7f153fdf [app] [I] Parameters:
{"name"=>"hostname.domain.com"}
2017-05-02 13:32:35 7f153fdf [app] [I] Rendered text template (0.0ms)
2017-05-02 13:32:35 7f153fdf [app] [I] Completed 200 OK in 80ms (Views:
0.5ms | ActiveRecord: 7.0ms)
2017-05-02 13:32:36 4fccfb22 [app] [I] Started POST "/api/config_reports"
for 10.121.66.130 at 2017-05-02 13:32:36 -0500
2017-05-02 13:32:36 4fccfb22 [app] [I] Processing by
Api::V2::ConfigReportsController#create as JSON
2017-05-02 13:32:36 4fccfb22 [app] [I] Parameters:
{"config_report"=>"[FILTERED]", "apiv"=>"v2"}
2017-05-02 13:32:36 4fccfb22 [app] [I] processing report for
hostname.domain.com
2017-05-02 13:32:36 4fccfb22 [app] [I] Imported report for
hostname.domain.com in 0.04 seconds
2017-05-02 13:32:36 4fccfb22 [app] [I] Rendered
api/v2/config_reports/create.json.rabl (10.5ms)
2017-05-02 13:32:36 4fccfb22 [app] [I] Completed 201 Created in 80ms
(Views: 10.9ms | ActiveRecord: 13.4ms)

And yet, still the Hosts tab in the Foreman GUI is empty. Thanks again,

Jarret

··· On Wednesday, April 19, 2017 at 1:57:40 PM UTC-5, J Webb wrote: > > Greetings, > > I have been unable to add hosts using "ansible -m setup hostname". > > I have recently installed Foreman 1.14.3 with the Katello scenario and the > Ansible plugin v 2.2.1.0 using "foreman-installer --scenario=katello > --enable-foreman-plugin-ansible". Everything seems to be working fine > except for no hosts are showing up using Ansible. > > I have successfully run a playbook on this host and followed these > instructions: > https://theforeman.org/plugins/foreman_ansible/1.x/index.html > > Here are the relevant config changes: > > /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py: > > FOREMAN_URL = os.getenv('FOREMAN_URL', "https://localhost") > > /etc/ansible/ansible.cfg: > [defaults] > callback_whitelist = foreman > ... > callback_plugins = > /usr/lib/python2.7/site-packages/ansible/plugins/callback > ... > bin_ansible_callbacks = True > > The host I'm trying to set up is in trusted_puppetmaster_hosts in Foreman > > ignore_puppet_facts_for_provisioning = No > > RESULTS: > > Running "ansible -m setup hostname" returns no errors, just a lot of > system info to stdout. Here are the foreman production.log entries during > the setup: > > 2017-04-19 12:53:09 58d05530 [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:09 -0500 > 2017-04-19 12:53:09 58d05530 [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:09 58d05530 [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:09 58d05530 [audit] [I] [hostname.domain.com] deleted 0 > (15.0ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] updated 18 > (594.4ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] added 0 > (6.2ms) > 2017-04-19 12:53:10 58d05530 [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 18, Deleted 0 facts > 2017-04-19 12:53:10 58d05530 [app] [I] Completed 201 Created in 755ms > (Views: 4.0ms | ActiveRecord: 103.9ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:10 -0500 > 2017-04-19 12:53:10 c522a2fd [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:10 c522a2fd [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] deleted 0 > (18.9ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] updated 0 > (532.0ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] added 0 > (6.4ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 0, Deleted 0 facts > 2017-04-19 12:53:10 c522a2fd [app] [I] Completed 201 Created in 687ms > (Views: 8.6ms | ActiveRecord: 94.1ms) > > Any advice is greatly appreciated. > > Jarret >

Hi friends ,

Me too trying to setup foreman latest 1.15 with ansible latest 2.3 ,but
always getting one or other error .

It seems foreman doc missing something .

Kindly update if any done this ,and what are steps need to be followed or
changes we need to make at foreman dashboard too .

Thanks in Advance

With Regards :

Shyam Keshri

··· On Thursday, April 20, 2017 at 12:27:40 AM UTC+5:30, J Webb wrote: > > Greetings, > > I have been unable to add hosts using "ansible -m setup hostname". > > I have recently installed Foreman 1.14.3 with the Katello scenario and the > Ansible plugin v 2.2.1.0 using "foreman-installer --scenario=katello > --enable-foreman-plugin-ansible". Everything seems to be working fine > except for no hosts are showing up using Ansible. > > I have successfully run a playbook on this host and followed these > instructions: > https://theforeman.org/plugins/foreman_ansible/1.x/index.html > > Here are the relevant config changes: > > /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py: > > FOREMAN_URL = os.getenv('FOREMAN_URL', "https://localhost") > > /etc/ansible/ansible.cfg: > [defaults] > callback_whitelist = foreman > ... > callback_plugins = > /usr/lib/python2.7/site-packages/ansible/plugins/callback > ... > bin_ansible_callbacks = True > > The host I'm trying to set up is in trusted_puppetmaster_hosts in Foreman > > ignore_puppet_facts_for_provisioning = No > > RESULTS: > > Running "ansible -m setup hostname" returns no errors, just a lot of > system info to stdout. Here are the foreman production.log entries during > the setup: > > 2017-04-19 12:53:09 58d05530 [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:09 -0500 > 2017-04-19 12:53:09 58d05530 [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:09 58d05530 [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:09 58d05530 [audit] [I] [hostname.domain.com] deleted 0 > (15.0ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] updated 18 > (594.4ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] added 0 > (6.2ms) > 2017-04-19 12:53:10 58d05530 [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 18, Deleted 0 facts > 2017-04-19 12:53:10 58d05530 [app] [I] Completed 201 Created in 755ms > (Views: 4.0ms | ActiveRecord: 103.9ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:10 -0500 > 2017-04-19 12:53:10 c522a2fd [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:10 c522a2fd [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] deleted 0 > (18.9ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] updated 0 > (532.0ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] added 0 > (6.4ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 0, Deleted 0 facts > 2017-04-19 12:53:10 c522a2fd [app] [I] Completed 201 Created in 687ms > (Views: 8.6ms | ActiveRecord: 94.1ms) > > Any advice is greatly appreciated. > > Jarret >

Hi! I'm quite new to Ansible and Foreman, the way I make the facts working
is by changing the Foreman callback function that comes with Ansible,
following what was described in this link
https://github.com/theforeman/foreman_ansible/issues/86#issuecomment-302123143 [before
make changes to the file, make a backup of it]
Plus, I've created a new ssh key on my foreman machine, and I've exported
it on my hosts for the user 'foreman', to make it able to connect on the
hosts with SSH.
But maybe is better to create a 'foreman' user on the hosts: I'm not sure.
Best.
Pietro Gabelli

··· On Wednesday, April 19, 2017 at 8:57:40 PM UTC+2, J Webb wrote: > > Greetings, > > I have been unable to add hosts using "ansible -m setup hostname". > > I have recently installed Foreman 1.14.3 with the Katello scenario and the > Ansible plugin v 2.2.1.0 using "foreman-installer --scenario=katello > --enable-foreman-plugin-ansible". Everything seems to be working fine > except for no hosts are showing up using Ansible. > > I have successfully run a playbook on this host and followed these > instructions: > https://theforeman.org/plugins/foreman_ansible/1.x/index.html > > Here are the relevant config changes: > > /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py: > > FOREMAN_URL = os.getenv('FOREMAN_URL', "https://localhost") > > /etc/ansible/ansible.cfg: > [defaults] > callback_whitelist = foreman > ... > callback_plugins = > /usr/lib/python2.7/site-packages/ansible/plugins/callback > ... > bin_ansible_callbacks = True > > The host I'm trying to set up is in trusted_puppetmaster_hosts in Foreman > > ignore_puppet_facts_for_provisioning = No > > RESULTS: > > Running "ansible -m setup hostname" returns no errors, just a lot of > system info to stdout. Here are the foreman production.log entries during > the setup: > > 2017-04-19 12:53:09 58d05530 [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:09 -0500 > 2017-04-19 12:53:09 58d05530 [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:09 58d05530 [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:09 58d05530 [audit] [I] [hostname.domain.com] deleted 0 > (15.0ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] updated 18 > (594.4ms) > 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] added 0 > (6.2ms) > 2017-04-19 12:53:10 58d05530 [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 18, Deleted 0 facts > 2017-04-19 12:53:10 58d05530 [app] [I] Completed 201 Created in 755ms > (Views: 4.0ms | ActiveRecord: 103.9ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Started POST "/api/v2/hosts/facts" > for 10.121.66.130 at 2017-04-19 12:53:10 -0500 > 2017-04-19 12:53:10 c522a2fd [app] [I] Processing by > Api::V2::HostsController#facts as JSON > 2017-04-19 12:53:10 c522a2fd [app] [I] Parameters: > {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", > :host=>{"name"=>"hostname.domain.com"}} > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] deleted 0 > (18.9ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] updated 0 > (532.0ms) > 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] added 0 > (6.4ms) > 2017-04-19 12:53:10 c522a2fd [app] [I] Import facts for ' > hostname.domain.com' completed. Added: 0, Updated: 0, Deleted 0 facts > 2017-04-19 12:53:10 c522a2fd [app] [I] Completed 201 Created in 687ms > (Views: 8.6ms | ActiveRecord: 94.1ms) > > Any advice is greatly appreciated. > > Jarret >

IIRC, just doing setup is not enough for the hosts to appear in foreman. I
think I created a very simple play (just the shell module doing 'w') and
had all the hosts execute that.

··· On Friday, April 21, 2017 at 12:52:08 AM UTC+2, J Webb wrote: > > Sorry I pasted "foreman.py" in the original post. It is > "foreman_callback.py" obtained using the url from the manual. "localhost" > was replaced with the FQDN of my Foreman host, now the modifications are: > > FOREMAN_URL = os.getenv('FOREMAN_URL', "https://myforemanhost.domain.com") > # Substitute by a real SSL certificate and key if your Foreman uses HTTPS > FOREMAN_SSL_CERT = (os.getenv('FOREMAN_SSL_CERT', > "/etc/foreman/client_cert.pem"), > os.getenv('FOREMAN_SSL_KEY', > "/etc/foreman/client_key.pem")) > FOREMAN_SSL_VERIFY = os.getenv('FOREMAN_SSL_VERIFY', "0") > > Yet still no hosts show up in Foreman after running "ansible -m setup > ...". Thanks! > > > On Wednesday, April 19, 2017 at 1:57:40 PM UTC-5, J Webb wrote: >> >> Greetings, >> >> I have been unable to add hosts using "ansible -m setup hostname". >> >> I have recently installed Foreman 1.14.3 with the Katello scenario and >> the Ansible plugin v 2.2.1.0 using "foreman-installer --scenario=katello >> --enable-foreman-plugin-ansible". Everything seems to be working fine >> except for no hosts are showing up using Ansible. >> >> I have successfully run a playbook on this host and followed these >> instructions: >> https://theforeman.org/plugins/foreman_ansible/1.x/index.html >> >> Here are the relevant config changes: >> >> /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py: >> >> FOREMAN_URL = os.getenv('FOREMAN_URL', "https://localhost") >> >> /etc/ansible/ansible.cfg: >> [defaults] >> callback_whitelist = foreman >> ... >> callback_plugins = >> /usr/lib/python2.7/site-packages/ansible/plugins/callback >> ... >> bin_ansible_callbacks = True >> >> The host I'm trying to set up is in trusted_puppetmaster_hosts in Foreman >> >> ignore_puppet_facts_for_provisioning = No >> >> RESULTS: >> >> Running "ansible -m setup hostname" returns no errors, just a lot of >> system info to stdout. Here are the foreman production.log entries during >> the setup: >> >> 2017-04-19 12:53:09 58d05530 [app] [I] Started POST "/api/v2/hosts/facts" >> for 10.121.66.130 at 2017-04-19 12:53:09 -0500 >> 2017-04-19 12:53:09 58d05530 [app] [I] Processing by >> Api::V2::HostsController#facts as JSON >> 2017-04-19 12:53:09 58d05530 [app] [I] Parameters: >> {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", >> :host=>{"name"=>"hostname.domain.com"}} >> 2017-04-19 12:53:09 58d05530 [audit] [I] [hostname.domain.com] deleted 0 >> (15.0ms) >> 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] updated >> 18 (594.4ms) >> 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] added 0 >> (6.2ms) >> 2017-04-19 12:53:10 58d05530 [app] [I] Import facts for ' >> hostname.domain.com' completed. Added: 0, Updated: 18, Deleted 0 facts >> 2017-04-19 12:53:10 58d05530 [app] [I] Completed 201 Created in 755ms >> (Views: 4.0ms | ActiveRecord: 103.9ms) >> 2017-04-19 12:53:10 c522a2fd [app] [I] Started POST "/api/v2/hosts/facts" >> for 10.121.66.130 at 2017-04-19 12:53:10 -0500 >> 2017-04-19 12:53:10 c522a2fd [app] [I] Processing by >> Api::V2::HostsController#facts as JSON >> 2017-04-19 12:53:10 c522a2fd [app] [I] Parameters: >> {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", >> :host=>{"name"=>"hostname.domain.com"}} >> 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] deleted 0 >> (18.9ms) >> 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] updated 0 >> (532.0ms) >> 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] added 0 >> (6.4ms) >> 2017-04-19 12:53:10 c522a2fd [app] [I] Import facts for ' >> hostname.domain.com' completed. Added: 0, Updated: 0, Deleted 0 facts >> 2017-04-19 12:53:10 c522a2fd [app] [I] Completed 201 Created in 687ms >> (Views: 8.6ms | ActiveRecord: 94.1ms) >> >> Any advice is greatly appreciated. >> >> Jarret >> >

Hi,

I have got the same version of Foreman and Ansible. In my case running
ansible setup was just enough (+ edit Ansible.cfg). However, I had to
download and edit foreman_callback.py. because even though they claimed on
the ansible plugin page that callback plugin is integrated since Ansible
2.2 this integrated callback plugin didn't work.
Btw. I couldn't get working foreman_callback.py with Ansible 2.3.0 from
testing repo.

Dňa pondelok, 24. apríla 2017 15:53:25 UTC+2 JM napísal(-a):

··· > > IIRC, just doing setup is not enough for the hosts to appear in foreman. I > think I created a very simple play (just the shell module doing 'w') and > had all the hosts execute that. > > On Friday, April 21, 2017 at 12:52:08 AM UTC+2, J Webb wrote: >> >> Sorry I pasted "foreman.py" in the original post. It is >> "foreman_callback.py" obtained using the url from the manual. "localhost" >> was replaced with the FQDN of my Foreman host, now the modifications are: >> >> FOREMAN_URL = os.getenv('FOREMAN_URL', "https://myforemanhost.domain.com >> ") >> # Substitute by a real SSL certificate and key if your Foreman uses HTTPS >> FOREMAN_SSL_CERT = (os.getenv('FOREMAN_SSL_CERT', >> "/etc/foreman/client_cert.pem"), >> os.getenv('FOREMAN_SSL_KEY', >> "/etc/foreman/client_key.pem")) >> FOREMAN_SSL_VERIFY = os.getenv('FOREMAN_SSL_VERIFY', "0") >> >> Yet still no hosts show up in Foreman after running "ansible -m setup >> ...". Thanks! >> >> >> On Wednesday, April 19, 2017 at 1:57:40 PM UTC-5, J Webb wrote: >>> >>> Greetings, >>> >>> I have been unable to add hosts using "ansible -m setup hostname". >>> >>> I have recently installed Foreman 1.14.3 with the Katello scenario and >>> the Ansible plugin v 2.2.1.0 using "foreman-installer --scenario=katello >>> --enable-foreman-plugin-ansible". Everything seems to be working fine >>> except for no hosts are showing up using Ansible. >>> >>> I have successfully run a playbook on this host and followed these >>> instructions: >>> https://theforeman.org/plugins/foreman_ansible/1.x/index.html >>> >>> Here are the relevant config changes: >>> >>> /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py: >>> >>> FOREMAN_URL = os.getenv('FOREMAN_URL', "https://localhost") >>> >>> /etc/ansible/ansible.cfg: >>> [defaults] >>> callback_whitelist = foreman >>> ... >>> callback_plugins = >>> /usr/lib/python2.7/site-packages/ansible/plugins/callback >>> ... >>> bin_ansible_callbacks = True >>> >>> The host I'm trying to set up is in trusted_puppetmaster_hosts in Foreman >>> >>> ignore_puppet_facts_for_provisioning = No >>> >>> RESULTS: >>> >>> Running "ansible -m setup hostname" returns no errors, just a lot of >>> system info to stdout. Here are the foreman production.log entries during >>> the setup: >>> >>> 2017-04-19 12:53:09 58d05530 [app] [I] Started POST >>> "/api/v2/hosts/facts" for 10.121.66.130 at 2017-04-19 12:53:09 -0500 >>> 2017-04-19 12:53:09 58d05530 [app] [I] Processing by >>> Api::V2::HostsController#facts as JSON >>> 2017-04-19 12:53:09 58d05530 [app] [I] Parameters: >>> {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", >>> :host=>{"name"=>"hostname.domain.com"}} >>> 2017-04-19 12:53:09 58d05530 [audit] [I] [hostname.domain.com] deleted >>> 0 (15.0ms) >>> 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] updated >>> 18 (594.4ms) >>> 2017-04-19 12:53:10 58d05530 [audit] [I] [hostname.domain.com] added 0 >>> (6.2ms) >>> 2017-04-19 12:53:10 58d05530 [app] [I] Import facts for ' >>> hostname.domain.com' completed. Added: 0, Updated: 18, Deleted 0 facts >>> 2017-04-19 12:53:10 58d05530 [app] [I] Completed 201 Created in 755ms >>> (Views: 4.0ms | ActiveRecord: 103.9ms) >>> 2017-04-19 12:53:10 c522a2fd [app] [I] Started POST >>> "/api/v2/hosts/facts" for 10.121.66.130 at 2017-04-19 12:53:10 -0500 >>> 2017-04-19 12:53:10 c522a2fd [app] [I] Processing by >>> Api::V2::HostsController#facts as JSON >>> 2017-04-19 12:53:10 c522a2fd [app] [I] Parameters: >>> {"facts"=>"[FILTERED]", "name"=>"hostname.domain.com", "apiv"=>"v2", >>> :host=>{"name"=>"hostname.domain.com"}} >>> 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] deleted >>> 0 (18.9ms) >>> 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] updated >>> 0 (532.0ms) >>> 2017-04-19 12:53:10 c522a2fd [audit] [I] [hostname.domain.com] added 0 >>> (6.4ms) >>> 2017-04-19 12:53:10 c522a2fd [app] [I] Import facts for ' >>> hostname.domain.com' completed. Added: 0, Updated: 0, Deleted 0 facts >>> 2017-04-19 12:53:10 c522a2fd [app] [I] Completed 201 Created in 687ms >>> (Views: 8.6ms | ActiveRecord: 94.1ms) >>> >>> Any advice is greatly appreciated. >>> >>> Jarret >>> >>

I am experiencing this exact same behavior with foreman 2.5.3 and ansible 2.10. Has this issue ever been resolved?