Problem:
Starting an ansible role fails all time. It stops with:
" NoMethodError - undefined method `code’ for “500 Internal Server Error”:String"
I tested with ansible 2.7.0 and 2.6.1.
Expected outcome:
Foreman and Proxy versions:
ii foreman 1.19.0-1 amd64 Systems management web interface
ii foreman-cli 1.19.0-1 all metapackage providing hammer CLI for Foreman
ii foreman-debug 1.19.0-1 all provides support utility foreman-debug.
ii foreman-installer 1.19.0-1 all Automated puppet-based installer for The Foreman
ii foreman-postgresql 1.19.0-1 all metapackage providing PostgreSQL dependencies for Foreman
ii foreman-proxy 1.19.0-1 all RESTful proxies for DNS, DHCP, TFTP, and Puppet
ii foreman-vmware 1.19.0-1 all metapackage providing vmware dependencies for Foreman
ii ruby-foreman-ansible 2.2.9-1 all Foreman Ansible plugin
ii ruby-foreman-deface 1.2.0-1 all Foreman Deface Plugin Dependency
ii ruby-foreman-remote-execution 1.5.6-1 all Foreman Remote Execution Plugin
ii ruby-foreman-tasks 0.13.2-1 all Tasks management engine for Foreman.
ii ruby-foreman-tasks-core 0.2.5-1 all Foreman tasks - core bits
ii ruby-hammer-cli-foreman 0.14.0-1 all Foreman commands for Hammer
Foreman and Proxy plugin versions:
ii foreman-proxy 1.19.0-1 all RESTful proxies for DNS, DHCP, TFTP, and Puppet
ii ruby-smart-proxy-ansible 2.0.3-2 all Ansible support for Foreman smart proxy
ii ruby-smart-proxy-dynflow 0.2.1-1 all Dynflow runtime for Foreman smart proxy
ii ruby-smart-proxy-dynflow-core 0.2.1-1 all Dynflow runtime for Foreman smart proxy
Other relevant data:
Input:
{"ansible_inventory"=>
"{\"all\":{\"hosts\":[\"mmfrontend01\"],\"vars\":{}},\"_meta\":{\"hostvars\":{\"mmfrontend01\":{\"foreman\":{\"ip\":\"172.21.200.51\",\"ip6\":\"\",\"environment_id\":2,\"environment_name\":\"QA\",\"last_report\":\"2018-10-18T08:04:36.000Z\",\"mac\":\"00:0c:29:7d:68:90\",\"realm_id\":null,\"realm_name\":null,\"sp_mac\":null,\"sp_ip\":null,\"sp_name\":null,\"domain_id\":null,\"domain_name\":null,\"architecture_id\":1,\"architecture_name\":\"x86_64\",\"operatingsystem_id\":1,\"operatingsystem_name\":\"Ubuntu 16.04.5 LTS\",\"subnet_id\":null,\"subnet_name\":null,\"subnet6_id\":null,\"subnet6_name\":null,\"sp_subnet_id\":null,\"ptable_id\":null,\"ptable_name\":null,\"medium_id\":null,\"medium_name\":null,\"pxe_loader\":null,\"build\":false,\"comment\":\"\",\"disk\":null,\"installed_at\":null,\"model_id\":1,\"hostgroup_id\":1,\"owner_id\":4,\"owner_name\":\"Admin User\",\"owner_type\":\"User\",\"enabled\":true,\"managed\":false,\"use_image\":null,\"image_file\":\"\",\"uuid\":null,\"compute_resource_id\":null,\"compute_resource_name\":null,\"compute_profile_id\":null,\"compute_profile_name\":null,\"capabilities\":[\"build\"],\"provision_method\":\"build\",\"certname\":\"mmfrontend01\",\"image_id\":null,\"image_name\":null,\"created_at\":\"2018-10-18T07:59:49.824Z\",\"updated_at\":\"2018-10-18T08:07:25.365Z\",\"last_compile\":\"2018-10-18T08:04:35.000Z\",\"global_status\":0,\"global_status_label\":\"Error\",\"puppet_status\":0,\"model_name\":\"VMware Virtual Platform\",\"configuration_status\":0,\"configuration_status_label\":\"Out of sync\",\"execution_status\":1,\"execution_status_label\":\"Last execution failed\",\"name\":\"mmfrontend01\",\"id\":2,\"puppet_proxy_id\":null,\"puppet_proxy_name\":null,\"puppet_ca_proxy_id\":null,\"puppet_ca_proxy_name\":null,\"puppet_proxy\":null,\"puppet_ca_proxy\":null,\"hostgroup_name\":\"development\",\"hostgroup_title\":\"development\"},\"foreman_params\":{\"qa-mmfrontend01\":\"system_hostname: qa-mmfrontend02\",\"remote_execution_ssh_user\":\"root\",\"remote_execution_effective_user_method\":\"sudo\",\"remote_execution_connect_by_ip\":false},\"foreman_ansible_roles\":[\"ubuntu-server\"],\"ansible_connection\":\"ssh\",\"ansible_ssh_private_key_file\":\"~/.ssh/id_rsa_foreman_proxy\",\"ansible_winrm_server_cert_validation\":\"validate\",\"ansible_become_user\":\"root\",\"ansible_user\":\"root\",\"ansible_ssh_pass\":null,\"ansible_port\":\"22\",\"ansible_become\":true,\"ansible_ssh_port\":\"22\",\"ansible_ssh_user\":\"root\",\"remote_execution_ssh_user\":\"root\",\"remote_execution_effective_user_method\":\"sudo\",\"qa-mmfrontend01\":\"system_hostname: qa-mmfrontend02\",\"remote_execution_connect_by_ip\":false}}}}",
"remote_execution_command"=>false,
"hostname"=>"mmfrontend01",
"script"=>
"---\n- hosts: all\n tasks:\n - name: Display all parameters known for the Foreman host\n debug:\n var: foreman_params\n roles:\n - ubuntu-server\n",
"execution_timeout_interval"=>nil,
"connection_options"=>{"retry_interval"=>15, "retry_count"=>4},
"proxy_url"=>"https://rzforeman01.nts.at:8443",
"proxy_action_name"=>"ForemanRemoteExecutionCore::Actions::RunScript",
"current_user_id"=>4}
```
Output:
```
{"metadata"=>
{"failed_proxy_tasks"=>
[{"proxy_task_id"=>nil,
"exception_class"=>"RestClient::InternalServerError",
"exception_message"=>"500 Internal Server Error",
"timestamp"=>1539854275.89703},
{"proxy_task_id"=>nil,
"exception_class"=>"RestClient::InternalServerError",
"exception_message"=>"500 Internal Server Error",
"timestamp"=>1539854291.01306},
{"proxy_task_id"=>nil,
"exception_class"=>"RestClient::InternalServerError",
"exception_message"=>"500 Internal Server Error",
"timestamp"=>1539854306.11337},
{"proxy_task_id"=>nil,
"exception_class"=>"RestClient::InternalServerError",
"exception_message"=>"500 Internal Server Error",
"timestamp"=>1539854321.22164}]},
"proxy_task_id"=>nil}
```
Exception:
RestClient::InternalServerError: 500 Internal Server Error
```
/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'
/usr/lib/ruby/2.3.0/net/http.rb:853:in `start'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:715:in `transmit'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rest-client-2.0.2/lib/restclient/resource.rb:67:in `post'
/usr/share/foreman/lib/proxy_api/resource.rb:78:in `block (2 levels) in post'
/usr/share/foreman/app/services/foreman/telemetry_helper.rb:27:in `telemetry_duration_histogram'
/usr/share/foreman/lib/proxy_api/resource.rb:77:in `block in post'
/usr/share/foreman/lib/proxy_api/resource.rb:105:in `with_logger'
/usr/share/foreman/lib/proxy_api/resource.rb:76:in `post'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb:22:in `trigger_task'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/proxy_action.rb:66:in `block in trigger_proxy_task'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:436:in `suspend'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/proxy_action.rb:65:in `trigger_proxy_task'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/proxy_action.rb:39:in `block in run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/proxy_action.rb:189:in `with_connection_error_handling'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/proxy_action.rb:33:in `run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:538:in `block (3 levels) in execute_run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:26:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware.rb:18:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware.rb:31:in `run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:26:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware.rb:18:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/middleware/rails_executor_wrap.rb:14:in `block in run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/execution_wrapper.rb:85:in `wrap'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/middleware/rails_executor_wrap.rb:13:in `run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:26:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware.rb:18:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action/progress.rb:30:in `with_progress_calculation'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action/progress.rb:16:in `run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:26:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware.rb:18:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/middleware/keep_current_user.rb:15:in `block in run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/middleware/keep_current_user.rb:43:in `restore_curent_user'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/lib/actions/middleware/keep_current_user.rb:15:in `run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:26:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware.rb:18:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware.rb:31:in `run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/stack.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/middleware/world.rb:30:in `execute'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:537:in `block (2 levels) in execute_run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:536:in `catch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:536:in `block in execute_run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:451:in `block in with_error_handling'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:451:in `catch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:451:in `with_error_handling'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:531:in `execute_run'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/action.rb:278:in `execute'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:17:in `block (2 levels) in execute'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/execution_plan/steps/abstract.rb:162:in `with_meta_calculation'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:16:in `block in execute'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:30:in `open_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:15:in `execute'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/director.rb:56:in `execute'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/executors/parallel/worker.rb:12:in `block in on_message'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/executors.rb:12:in `run_user_code'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/executors/parallel/worker.rb:11:in `on_message'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/context.rb:46:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/executes_context.rb:7:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/dynflow-1.1.0/lib/dynflow/actor.rb:26:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/awaits.rb:15:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/sets_results.rb:14:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/buffer.rb:38:in `process_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/buffer.rb:31:in `process_envelopes?'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/buffer.rb:20:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/termination.rb:55:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/removes_child.rb:10:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/behaviour/sets_results.rb:14:in `on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/core.rb:161:in `process_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/core.rb:95:in `block in on_envelope'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/core.rb:118:in `block (2 levels) in schedule_execution'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `block in synchronize'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-edge-0.2.4/lib/concurrent/actor/core.rb:115:in `block in schedule_execution'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/serialized_execution.rb:18:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/serialized_execution.rb:96:in `work'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/serialized_execution.rb:77:in `block in call_job'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'
/usr/share/foreman/vendor/ruby/2.3.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
```