Couldn't retrieve ENC data

Problem:

# /usr/bin/foreman-node host1.master.vm
Couldn't retrieve ENC data: Error retrieving node host1.master.vm: Net::HTTPNotFound
# /usr/bin/foreman-node salt.master.vm
Could not get grains: undefined method `merge' for nil:NilClass

I’m trying to get my host to appear on the webfrontend all to no avail, can someone please help me figure out what my config problem might be?

cat /etc/salt/foreman.yaml
---
:proto: https
:host: foreman.master.vm
:port: 8443
# if using http with ssl certificates
:ssl_ca: "/etc/puppetlabs/puppet/ssl/certs/ca.pem"
:ssl_cert: "/etc/puppetlabs/puppet/ssl/certs/salt.master.vm.pem"
:ssl_key: "/etc/puppetlabs/puppet/ssl/private_keys/salt.master.vm.pem"
# if using http with username and password instead of https with certicates
#:username: admin
#:password: changeme
:timeout:  10
:salt:  /usr/bin/salt
:upload_grains:  true

Expected outcome:

Foreman and Proxy versions:
RELEASE: CentOS Linux release 7.5.1804 (Core)
FOREMAN: 1.17.1
RUBY: ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
PUPPET: 5.5.2
DENIALS: 0

salt-api 2018.3.2 (Oxygen)
salt --version == salt 2018.3.2 (Oxygen)

foreman_salt-10.0.0-2
rubygem-smart_proxy_salt-2.1.9-1.el7

Foreman and Proxy plugin versions:

Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]

The HTTP Not Found error is your clue - the ENC script cannot find the Foreman server to ask for ENC data.

And this is probably why. 8443 is the port used by the proxy, not Foreman itself. Foreman uses normal HTTPS on port 443, which is probably what you want there.

1 Like

Thanks for the response
I have made the corrections as specified but still getting the same error


:proto: https
:host: foreman.master.vm
:port: 443

if using http with ssl certificates

:ssl_ca: “/etc/puppetlabs/puppet/ssl/certs/ca.pem”
:ssl_cert: “/etc/puppetlabs/puppet/ssl/certs/salt.master.vm.pem”
:ssl_key: “/etc/puppetlabs/puppet/ssl/private_keys/salt.master.vm.pem”

if using http with username and password instead of https with certicates

#:username: admin
#:password: changeme
:timeout: 10
:salt: /usr/bin/salt
:upload_grains: true

/usr/bin/foreman-node host1.master.vm
Couldn’t retrieve ENC data: Error retrieving node host1.master.vm: Net::HTTPNotFound
Check Foreman’s /var/log/foreman/production.log for more information.

Couldn’t retrieve ENC data: Error retrieving node salt.master.vm: Net::HTTPNotFound
Check Foreman’s /var/log/foreman/production.log for more information.

/var/log/foreman/production.log

2018-07-23T07:46:38 d022bb6e [app] [I] Rendering api/v2/errors/standard_error.json.rabl within api/v2/layouts/error_layout
2018-07-23T07:46:38 d022bb6e [app] [I] Rendered api/v2/errors/standard_error.json.rabl within api/v2/layouts/error_layout (35.3ms)
2018-07-23T07:46:38 d022bb6e [app] [I] Completed 500 Internal Server Error in 297ms (Views: 36.3ms | ActiveRecord: 32.4ms)
2018-07-23T07:46:38 813bf509 [app] [I] Started GET “/salt/node/host1.master.vm?format=yml” for 10.1.26.82 at 2018-07-23 07:46:38 -0400
2018-07-23T07:46:38 813bf509 [app] [I] Processing by ForemanSalt::MinionsController#node as YML
2018-07-23T07:46:38 813bf509 [app] [I] Parameters: {“id”=>“host1.master.vm”}
2018-07-23T07:46:38 813bf509 [app] [I] Completed 404 Not Found in 3ms (ActiveRecord: 0.6ms)

Jul 23 07:52:00 salt.master.vm salt-master[4367]: [WARNING ] Wrong permissions for /etc/salt/autosign.conf, ignoring content
Jul 23 07:52:02 salt.master.vm salt-master[4367]: [ERROR ] Command ‘[u’/usr/bin/foreman-node’, u’salt.master.vm’]’ failed with return code: 1
Jul 23 07:52:02 salt.master.vm salt-master[4367]: [ERROR ] stdout: Couldn’t retrieve ENC data: Error retrieving node salt.master.vm: Net::HTTPNotFound
Jul 23 07:52:02 salt.master.vm salt-master[4367]: Check Foreman’s /var/log/foreman/production.log for more information.
Jul 23 07:52:02 salt.master.vm salt-master[4367]: [ERROR ] retcode: 1
Jul 23 07:52:02 salt.master.vm salt-master[4367]: [ERROR ] Command ‘/usr/bin/foreman-node salt.master.vm’ failed with return code: 1
Jul 23 07:52:02 salt.master.vm salt-master[4367]: [ERROR ] output: Couldn’t retrieve ENC data: Error retrieving node salt.master.vm: Net::HTTPNotFound
Jul 23 07:52:02 salt.master.vm salt-master[4367]: Check Foreman’s /var/log/foreman/production.log for more information.
Jul 23 07:52:02 salt.master.vm salt-master[4367]: [CRITICAL] YAML data from /usr/bin/foreman-node failed to parse

We’ll need a much longer output from production.log. Try using tail -f /var/log/foreman/production.log before you run the ENC, and then capture the whole output of the request for node data.

Side note, there is an issue with fact/grain uploads in 10.0.0, you may want to upgrade to 10.1.0 once this PR is merged:

https://pastebin.com/eu27PqWB

Attached is the requested output /var/log/foreman/production.log

Yeah, you’re hitting the salt bug - you can see it here:

2018-07-23T08:23:18 dd2bb631 [app] [W] Rolling back due to exception during save

You’ll want to grab foreman_salt 10.1.0, although it’s waiting on @packaging to merge the build for RPMs…

That’s fine I’ll wait, I thought I had my configurations all wrong.

Thanks for the response.