Unable to add smart proxies to foreman

I am trying to add a puppet smart proxy to my foreman server, but not
having any luck.

All hosts are RHEL 6.4. I am running puppet enterprise 3.1.0 and foreman
1.3.1 installed via packages.

The puppet master is behind a load balancer/proxy (nginx) but that does not
seem to be the issue as far as I can tell.

When I add the smart proxy in foreman, I get the following error:

Unable to save
Unable to communicate with the proxy: Feature(#61541240) expected, got
NilClass(#15845480)
Please check the proxy is configured and running on the host.

However, when I send the request manually via curl, it returns data:

root@foreman# curl --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem -H
"Content-Type:application/json" -H "Accept:application/json"
https://puppet:9443/features
["puppet"]

The logs on the nginx proxy box show the same 200 code indicating success:
10.1.105.123 - - [07/Jan/2014:12:43:29 -0500] "GET /features HTTP/1.1" 200
10 "-" "Ruby"
10.1.105.123 - - [07/Jan/2014:12:49:43 -0500] "GET /features HTTP/1.1" 200
10 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0
zlib/1.2.3 libidn/1.18 libssh2/1.4.2"

The first line is when I tried to add the smart proxy via the foreman web
gui, the second line is when I sent the above curl command.

However, on the puppet master running the foreman-proxy a logfile entry is
only made when I send the request via curl.

My foreman-proxy config is as follows (comments removed for brevity)

··· --- :ssl_certificate: /etc/puppetlabs/puppet/ssl/certs/puppet.companyname.com.pem :ssl_ca_file: /etc/puppetlabs/puppet/ssl/certs/ca.pem :ssl_private_key: /etc/puppetlabs/puppet/ssl/private_keys/puppet.companyname.com.pem :foreman_url: https://foreman.companyname.com :daemon: true :daemon_pid: /var/run/foreman-proxy/foreman-proxy.pid :port: 9443 :tftp: false :tftproot: /var/lib/tftpboot :dns: false :dns_provider: nsupdate :dhcp: false :dhcp_vendor: isc :virsh_network: default :puppetca: false :puppet: true :puppet_provider: mcollective :customrun_cmd: /bin/false :customrun_args: -ay -f -s :puppet_conf: /etc/puppetlabs/puppet/puppet.conf :puppetssh_sudo: false :puppetssh_command: /usr/bin/puppet agent --onetime --no-usecacheonfailure :chefproxy: false :bmc: false :log_file: /var/log/foreman-proxy/proxy.log :log_level: DEBUG

> Unable to communicate with the proxy: Feature(#61541240) expected, got
> NilClass(#15845480)

Hello,

can you find full backtrace for this ^^ error in production.log or
proxy.log and paste it here?

LZ

··· -- Later,

Lukas “lzap” Zapletal
irc: lzap #theforeman

> Unable to save
> Unable to communicate with the proxy: Feature(#61541240) expected, got
> NilClass(#15845480)
> Please check the proxy is configured and running on the host.

Ok after quick chat with Dominic it looks like you are missing features
in the database. Is this clean installation or upgrade?

You are missing some bits in the "features" table. Try to re-migrate
database (it should only check if there are not pending migrations).
Also check the database, table "features":

Loading development environment (Rails 3.2.15)
>> Feature.all
Feature Load (0.1ms) SELECT "features".* FROM "features"

··· +----+-----------+-------------------------+-------------------------+ > id | name | created_at | updated_at | +----+-----------+-------------------------+-------------------------+ > 1 | TFTP | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > 2 | DNS | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > 3 | DHCP | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > 4 | Puppet CA | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > 5 | Puppet | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > 6 | BMC | 2013-10-30 12:32:30 UTC | 2013-10-30 12:32:30 UTC | +----+-----------+-------------------------+-------------------------+ 6 rows in set

If your database is clean, drop it and create a new one, then migrate.

LZ


Later,

Lukas “lzap” Zapletal
irc: lzap #theforeman

Sure, here you go. Also, the same exact thing happens when if use the FQDN
for the puppet master instead of just "puppet"

Started POST "/smart_proxies" for 10.10.10.10 at 2014-01-08 09:31:59 -0500
Processing by SmartProxiesController#create as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"9S+BrJdMJNBWfoS7IWfYCZqsThB0vIE3SjXsP3zpQ24=",
"smart_proxy"=>{"name"=>"Puppet", "url"=>"https://puppet:9443",
"location_ids"=>[""], "organization_ids"=>[""]}, "commit"=>"Submit"}
WARNING: Can't verify CSRF token authenticity
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."login" =
'admin' LIMIT 1
Setting current user thread-local variable to admin
(0.3ms) SELECT COUNT() FROM "taxonomies" WHERE "taxonomies"."type" IN
('Organization')
Setting current organization thread-local variable to none
(0.3ms) SELECT COUNT(
) FROM "taxonomies" WHERE "taxonomies"."type" IN
('Location')
Setting current location thread-local variable to none
(0.3ms) SELECT id FROM "taxonomies" WHERE "taxonomies"."type" IN
('Location') LIMIT 1
(0.3ms) SELECT id FROM "taxonomies" WHERE "taxonomies"."type" IN
('Organization') LIMIT 1
(0.3ms) BEGIN
SmartProxy Exists (0.3ms) SELECT 1 AS one FROM "smart_proxies" WHERE
"smart_proxies"."name" = 'Puppet' LIMIT 1
SmartProxy Exists (0.3ms) SELECT 1 AS one FROM "smart_proxies" WHERE
"smart_proxies"."url" = 'https://puppet:9443' LIMIT 1
Feature Load (0.3ms) SELECT "features".* FROM "features" WHERE
"features"."name" = 'TFTP' LIMIT 1
Feature Load (0.3ms) SELECT "features".* FROM "features" WHERE
"features"."name" = 'BMC' LIMIT 1
Feature Load (0.3ms) SELECT "features".* FROM "features" WHERE
"features"."name" = 'DNS' LIMIT 1
Feature Load (0.3ms) SELECT "features".* FROM "features" WHERE
"features"."name" = 'DHCP' LIMIT 1
Feature Load (0.3ms) SELECT "features".* FROM "features" WHERE
"features"."name" = 'Puppet CA' LIMIT 1
Feature Load (0.3ms) SELECT "features".* FROM "features" WHERE
"features"."name" = 'Puppet' LIMIT 1
Setting Load (0.4ms) SELECT "settings".* FROM "settings" WHERE
"settings"."name" = 'ssl_certificate' ORDER BY name LIMIT 1
Setting Load (0.4ms) SELECT "settings".* FROM "settings" WHERE
"settings"."name" = 'ssl_ca_file' ORDER BY name LIMIT 1
Setting Load (0.3ms) SELECT "settings".* FROM "settings" WHERE
"settings"."name" = 'ssl_priv_key' ORDER BY name LIMIT 1
(0.4ms) ROLLBACK
Failed to save: Unable to communicate with the proxy: Feature(#62146120)
expected, got NilClass(#10045540), Please check the proxy is configured and
running on the host.
CACHE (0.0ms) SELECT COUNT() FROM "taxonomies" WHERE
"taxonomies"."type" IN ('Location')
Location Load (0.5ms) SELECT "taxonomies".
FROM "taxonomies" WHERE
"taxonomies"."type" IN ('Location')
Taxonomy Load (0.6ms) SELECT taxonomies.id FROM "taxonomies" INNER JOIN
"taxable_taxonomies" ON "taxonomies"."id" =
"taxable_taxonomies"."taxonomy_id" WHERE "taxable_taxonomies"."taxable_id"
IS NULL AND "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND
(taxonomies.type='Location')
Rendered common/_edit_habtm.html.erb (2.2ms)
CACHE (0.0ms) SELECT COUNT() FROM "taxonomies" WHERE
"taxonomies"."type" IN ('Organization')
Organization Load (0.4ms) SELECT "taxonomies".
FROM "taxonomies" WHERE
"taxonomies"."type" IN ('Organization')
Taxonomy Load (0.4ms) SELECT taxonomies.id FROM "taxonomies" INNER JOIN
"taxable_taxonomies" ON "taxonomies"."id" =
"taxable_taxonomies"."taxonomy_id" WHERE "taxable_taxonomies"."taxable_id"
IS NULL AND "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND
(taxonomies.type='Organization')
Rendered common/_edit_habtm.html.erb (1.6ms)
Rendered smart_proxies/_form.html.erb (10.5ms)
Rendered smart_proxies/new.html.erb within layouts/application (10.8ms)
Read fragment views/tabs_and_title_records-1 (0.1ms)
CACHE (0.0ms) SELECT COUNT() FROM "taxonomies" WHERE
"taxonomies"."type" IN ('Organization')
Organization Load (0.4ms) SELECT "taxonomies".
FROM "taxonomies" WHERE
"taxonomies"."type" IN ('Organization') ORDER BY type, name
Rendered home/_organization_dropdown.html.erb (2.5ms)
CACHE (0.0ms) SELECT COUNT() FROM "taxonomies" WHERE
"taxonomies"."type" IN ('Location')
Location Load (0.4ms) SELECT "taxonomies".
FROM "taxonomies" WHERE
"taxonomies"."type" IN ('Location') ORDER BY type, name
Rendered home/_location_dropdown.html.erb (2.4ms)
Rendered home/_org_switcher.html.erb (5.4ms)
Rendered home/_settings.html.erb (4.4ms)
Write fragment views/tabs_and_title_records-1 (0.8ms)
Rendered home/_topbar.html.erb (14.3ms)
Completed 200 OK in 108ms (Views: 25.1ms | ActiveRecord: 8.9ms)

··· On Wednesday, January 8, 2014 5:38:18 AM UTC-5, Lukas Zapletal wrote: > > > Unable to communicate with the proxy: Feature(#61541240) expected, got > > NilClass(#15845480) > > Hello, > > can you find full backtrace for this ^^ error in production.log or > proxy.log and paste it here? > > LZ > > -- > Later, > > Lukas "lzap" Zapletal > irc: lzap #theforeman >

Dropping and re-creating and migrating the db worked! Thank you for your
help!

Bill

··· On Wednesday, January 8, 2014 10:18:50 AM UTC-5, Lukas Zapletal wrote: > > > Unable to save > > Unable to communicate with the proxy: Feature(#61541240) expected, got > > NilClass(#15845480) > > Please check the proxy is configured and running on the host. > > Ok after quick chat with Dominic it looks like you are missing features > in the database. Is this clean installation or upgrade? > > You are missing some bits in the "features" table. Try to re-migrate > database (it should only check if there are not pending migrations). > Also check the database, table "features": > > Loading development environment (Rails 3.2.15) > >> Feature.all > Feature Load (0.1ms) SELECT "features".* FROM "features" > +----+-----------+-------------------------+-------------------------+ > > id | name | created_at | updated_at | > +----+-----------+-------------------------+-------------------------+ > > 1 | TFTP | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > > 2 | DNS | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > > 3 | DHCP | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > > 4 | Puppet CA | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > > 5 | Puppet | 2013-10-30 12:32:25 UTC | 2013-10-30 12:32:25 UTC | > > 6 | BMC | 2013-10-30 12:32:30 UTC | 2013-10-30 12:32:30 UTC | > +----+-----------+-------------------------+-------------------------+ > 6 rows in set > > If your database is clean, drop it and create a new one, then migrate. > > LZ > > -- > Later, > > Lukas "lzap" Zapletal > irc: lzap #theforeman >