Project

General

Profile

Bug #14778

Cannot use foreman-rake config to set complex (array) settings

Added by Luis Fernández almost 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Settings
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Hi,

I want to use the config option via foreman-rake to update the 'ignored_interface_identifiers' setting in Foreman but I'm facing some problems:

Tested on foreman 1.10.2:

$ /usr/sbin/foreman-rake -- config -k ignored_interface_identifiers
["lo"]
$ /usr/sbin/foreman-rake -- config -k ignored_interface_identifiers -v '["lo","awdl*"]'
"[\"lo\", \"awdl*\"]" 
$ /usr/sbin/foreman-rake -- config -k ignored_interface_identifiers
"[\"lo\", \"awdl*\"]" 

On this point, the foreman log shows some errors connected to the filtering of the interfaces:

2016-04-22 14:31:19 [app] [W] Action failed
 | NoMethodError: undefined method `map' for #<String:0x0000000931c938>
 | /usr/share/foreman/app/models/setting.rb:183:in `convert_array_to_regexp'
 | /usr/share/foreman/app/services/fact_parser.rb:166:in `ignored_interfaces'
 | /usr/share/foreman/app/services/fact_parser.rb:171:in `block in remove_ignored'

The way to solve it is to use the web UI and the setting is sanitized:

$ /usr/sbin/foreman-rake -- config -k ignored_interface_identifiers
["lo", "awdl*"]

I don't know if this is more connected to the foreman-rake or the implementation of the interface filtering.

Any feedback or tip is welcomed :)


Related issues

Related to Installer - Bug #15084: foreman_config_entry is not idempotent with arraysNew2016-05-18

Associated revisions

Revision 73d265f6 (diff)
Added by Luis Fernandez Alvarez almost 4 years ago

Fixes #14778 - Ensure parsing complex types keep target type

Without this patch, the config task would send complex types as
strings to the setting model.

This patch makes the parsed object to keep the target type and it
assumes the setting model will do the internal conversion (now to
yaml).

Revision db208ce0 (diff)
Added by Luis Fernandez Alvarez almost 4 years ago

Fixes #14778 - Ensure parsing complex types keep target type

Without this patch, the config task would send complex types as
strings to the setting model.

This patch makes the parsed object to keep the target type and it
assumes the setting model will do the internal conversion (now to
yaml).

(cherry picked from commit 73d265f6b21a03328697c9555f30d645534839ab)

History

#1 Updated by Dominic Cleal almost 4 years ago

  • Description updated (diff)

#2 Updated by Luis Fernández almost 4 years ago

It looks like on the following line, the 'complex' type is parse and an string is returned:

https://github.com/theforeman/foreman/blob/develop/lib/tasks/config.rake#L134

Could it be as simple as replacing it by just "JSON.parse(value)". I don't know if it could have other side-effects somewhere else.

Thanks!

#3 Updated by The Foreman Bot almost 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3461 added

#4 Updated by Anonymous almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#5 Updated by Dominic Cleal almost 4 years ago

  • Assignee set to Luis Fernández
  • Legacy Backlogs Release (now unused) set to 155

#6 Updated by Dominic Cleal almost 4 years ago

  • Related to Bug #15084: foreman_config_entry is not idempotent with arrays added

Also available in: Atom PDF