Foreman 3.3.1 - NoMethodError: undefined method `all?' - at foreman-rake config trusted hosts

Problem:
I have a problem setting up a new foreman-server.
I created a test-system before in which

foreman-rake -- config -k 'trusted_hosts' -v '<puppetmaster-0, puppetmaster-1'

NoMethodError: undefined method `all?' for #<String:0x000000001020c258>
/usr/share/foreman/app/validators/array_hostnames_ips_validator.rb:4:in `validate_each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.4.7/lib/active_model/validator.rb:152:in `block in validate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.4.7/lib/active_model/validator.rb:149:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.4.7/lib/active_model/validator.rb:149:in `validate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:428:in `block in make_lambda'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:181:in `block (2 levels) in halting_and_conditional'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:604:in `catch'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:604:in `block in default_terminator'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:182:in `block in halting_and_conditional'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:513:in `block in invoke_before'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:513:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:513:in `invoke_before'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:134:in `run_callbacks'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:825:in `_run_validate_callbacks'
/opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.4.7/lib/active_model/validations.rb:406:in `run_validations!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.4.7/lib/active_model/validations/callbacks.rb:117:in `block in run_validations!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:135:in `run_callbacks'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:825:in `_run_validation_callbacks'
/opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.4.7/lib/active_model/validations/callbacks.rb:117:in `run_validations!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.4.7/lib/active_model/validations.rb:337:in `valid?'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/validations.rb:68:in `valid?'
/usr/share/foreman/lib/tasks/config.rake:148:in `validate_and_save'
/usr/share/foreman/lib/tasks/config.rake:111:in `block in run_key_values'
/usr/share/foreman/lib/tasks/config.rake:100:in `each'
/usr/share/foreman/lib/tasks/config.rake:100:in `run_key_values'
/usr/share/foreman/lib/tasks/config.rake:77:in `run'
/usr/share/foreman/lib/tasks/config.rake:167:in `block in <top (required)>'
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => config
(See full trace by running task with --trace)

afterwards i tried also to execute following:

foreman-rake -- config -k 'update_environment_from_facts' -v true
ERROR: Invalid value true for update_environment_from_facts - ["Value is not included in the list"]

foreman-rake -- config -k 'enc_environment'
true

foreman-rake -- config -k 'enc_environment' -v false
ERROR: Invalid value false for enc_environment - ["Value is not included in the list"]

[root@foreman-000000 ~]# foreman-rake -- config -k 'enc_environment'
true

Expected outcome:

puppetmaster is added to trusted hosts in DB and enc_environment / update_environment_from_facts can changed values

Foreman and Proxy versions:
tfm-rubygem-hammer_cli_foreman-3.3.0-1.el7.noarch
tfm-rubygem-foreman_host_extra_validator-0.1.0-5.fm3_3.el7.noarch
foreman-selinux-3.3.1-1.el7.noarch
foreman-3.3.1-1.el7.noarch
foreman-proxy-3.3.1-1.el7.noarch
foreman-cli-3.3.1-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_remote_execution-0.2.2-1.fm3_0.el7.noarch
tfm-rubygem-foreman_puppet-4.0.4-1.fm3_3.el7.noarch
tfm-rubygem-foreman_salt-15.1.0-3.fm3_3.el7.noarch
foreman-release-3.3.1-1.el7.noarch
foreman-debug-3.3.1-1.el7.noarch
foreman-postgresql-3.3.1-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_azure_rm-0.2.2-1.fm3_1.el7.noarch
tfm-rubygem-hammer_cli_foreman_templates-0.2.0-2.fm2_5.el7.noarch
tfm-rubygem-foreman_azure_rm-2.2.7-1.fm3_3.el7.noarch
foreman-dynflow-sidekiq-3.3.1-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_puppet-0.0.6-1.fm3_3.el7.noarch
tfm-rubygem-foreman_discovery-21.0.5-1.fm3_3.el7.noarch
tfm-rubygem-foreman_expire_hosts-7.0.4-4.fm3_3.el7.noarch
tfm-rubygem-foreman-tasks-6.0.2-1.fm3_3.el7.noarch
foreman-service-3.3.1-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_tasks-0.0.17-1.fm3_2.el7.noarch
tfm-rubygem-foreman_remote_execution-7.2.2-1.fm3_3.el7.noarch
tfm-rubygem-foreman_templates-9.3.0-1.fm3_3.el7.noarch
foreman-installer-3.3.1-2.el7.noarch

Distribution and version:

CentOS Linux release 7.9.2009 (Core)

@ekohl, @evgeni or someone else from foreman-Developers / Community, could you please help / support me. maybe it is a not installed package, which creates the entries in the foreman-DB or so ?

Please don’t ping individuals, unless you have a specific question to them.

You gotta pass an array:

# foreman-rake -- config -k 'trusted_hosts' -v '["a","b"]'
trusted_hosts: ["a","b"]
# foreman-rake -- config -k 'trusted_hosts'
["a","b"]

No idea about te others, the seem to work for me:

# foreman-rake -- config -k 'update_environment_from_facts'
false
# foreman-rake -- config -k 'update_environment_from_facts' -v 'true'
update_environment_from_facts: true

But I am running this on 3.8, not 3.3.

it worked on my Development System without any problems before.
my productive system you can see the behaviour is different.

could this be something with the database ?

@evgeni,

was now able to solve the issue by myself.
Over the CLI it was not possible with foreman-rake to implement this with the above command.

After i added the values in the UI under “Managment/Authorisation/trusted_hosts” it seems he added the fields / columns to the database.

afterwards i was also able to execute the command on the CLI successfully.

a question to that,

is it possible, if the fields / columns if the fields / columns not exist to add them initially ?

because if you setup a new infrastructure with a new and empty DB then this issue would reappear and i guess it is not a good way to login to the UI to execute it like i did now

Well, you can use Ansible to set various settings, which seems nicer than foreman-rake?
Or you could use hammer.

Both will use the API under the hood, thus probably being safer than the rake method.