Foreman execute ansible role

Problem:
When i execute an ansible role at foreman it fails.
One Subtask fails:

Initialization error: RestClient::InternalServerError - 500 Internal Server Error
Initialization error: RestClient::InternalServerError - 500 Internal Server Error
Initialization error: RestClient::InternalServerError - 500 Internal Server Error
Initialization error: RestClient::InternalServerError - 500 Internal Server Error
Error loading data from proxy: NoMethodError - undefined method `code' for "500 Internal Server Error":String
Did you mean?  encode

Expected outcome:

Foreman and Proxy versions:
foreman & proxy 1.19.0-1

Foreman and Proxy plugin versions:
ruby-foreman-ansible 2.2.9-1
ansible 2.2.1.0-2

Other relevant data:
Syslog:

Nov  7 11:39:27 foreman smart-proxy[1512]: 2018-11-07 11:39:27 - NameError - uninitialized constant ForemanRemoteExecutionCore:

production.log:

2018-11-07T11:40:13 [E|bac|] 500 Internal Server Error (RestClient::InternalServerError)
/usr/share/foreman/vendor/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:223:in `exception_with_response'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:103:in `return!'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:809:in `process_result'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:725:in `block in transmit'

proxy.log:

W, [2018-11-07T11:28:58.236954 #1512]  WARN -- : Could not open DB for dynflow at '', will keep data in memory. Restart will drop all dynflow data.
[2018-11-07 11:28:58.567 #1512]  INFO -- Execution plan cleaner removing 0 execution plans.

Hi,
could you check if you have the ruby-foreman-remote-execution-core package installed?

Hello, thanks for your replay!
You mean this plugin?:
ruby-foreman-remote-execution

Yeah, it’s installed and enabled.

While installing the ansible plugin, i got this problem:

Maybe that’s the cause? I “fixed” it with this sed

ruby-foreman-remote-execution is only one piece of the puzzle, for things to work properly you need to also have ruby-foreman-remote-execution-core package installed.

1 Like

Now i got something like:
Proxy error: RuntimeError - Settings for ForemanRemoteExecutionCore not initalized
Exit status: EXCEPTION

For everyone who get’s the following error:

Don’t use the sed, just install the ruby-foreman-remote-execution-core package…

Proxy error: RuntimeError
Still exist’s

And you need the ssh plugin… Now i am finaly here:

UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n", "unreachable": true}

I generated the key like descripted at the Foreman manual (puppet_proxy_ssh)

Have you distributed the public key to the target host?

Yeah but it was the wrong user.
The ssh plugin is using the user root.
Ansibe is using foreman-proxy.
Idk why the ansible plugin isn’t using the ssh plugin user.
But yeah. Just add remote_user = root at ansible.cfg

It should be using the root user account by default. The foreman-proxy user account contains the private key used to login to your servers as root or whatever you designate in the settings tab.

Just a suggestion, it might be better to place that value in global param, OS param, host_group param, or somewhere else within the app. since changes in the ansible.cfg file get clobbered with updates from what I’ve seen. It also allows for more fine-grained control.

I wrote it into the ansible.cfg at the foreman-proxy directory. It should not be updated or am i wrong?

I’ve seen my changes clobbered there before after re-running foreman-installer.
You might have some luck placing your local settings in one of the locations with a higher priority.

Changes can be made and used in a configuration file which will be processed in the following order:

* ANSIBLE_CONFIG (an environment variable)
* ansible.cfg (in the current directory)
* .ansible.cfg (in the home directory)
* /etc/ansible/ansible.cfg

https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-configuration-settings

Thanks!
You are right.
The ansible.cfg got changed after executing foreman-installer.

  • ANSIBLE_CONFIG (an environment variable)
  • ansible.cfg (in the current directory)
  • .ansible.cfg (in the home directory)
  • /etc/ansible/ansible.cfg

Not working at all…
ANSIBLE_CONFIG=/root/.ansible.cfg
or
/etc/ansible/ansible.cfg

The config is not the “real” ansible config. Just a preconfig for foreman…