Bug #23382
closed
Editing Smart Class Parameter of type YAML creates malformed value in release 1.17.0
Added by Vadim Bulst over 6 years ago.
Updated over 6 years ago.
Description
When defining smart class parameter values with type YAML and submitted in GUI an Ruby error message gets prepended for each array entry.
Defining an YAML-Array like:
---
- name: foo
mount_point: /bar
- name: john
mount_point: /doe
gets saved as:
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
name: foo
mount_point: "/bar"
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
name: john
mount_point: "/doe"
Just a very simple example our YAML are much more complex. This error appears since the upgrade from 1.16.1 to 1.17.0.
As we need this system for production, we can leave this installation like it is for debugging purposes for a maximum of 36hours.
HOSTNAME: urzlxdeploy.rz.uni-leipzig.de
OS: redhat
RELEASE: CentOS Linux release 7.4.1708 (Core)
FOREMAN: 1.17.0
RUBY: ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
PUPPET: 4.10.11
DENIALS: 0
- Related to Bug #23463: YAML rendering of external nodes generates incorrect data if hashes are used added
- Translation missing: en.field_release changed from 296 to 297
Is there any quick fix? I have upgraded to 1.17.0 recently and now all my Puppet manifests fail because the hashes are malformed? Rails 5.1.7 isn't going to be released anytime soon, so I guess we need a fix for that.
Couldn't we just revert the change that introduced this issue from 1.16.x to 1.17.0?
- Translation missing: en.field_release changed from 297 to 360
Pushing out to 1.17.2, this won't be fixed in time for 1.17.1.
Well I fixed this in the meantime by manually editing the rails file as mentioned by Michael. Can't we just provide a patched rails release via the foreman repos?
The fix mentioned by Henry Spanka doesnt work for me. (Debian Stretch installed via DEB Repositoy)
@Tobias: Have you restarted foreman (Webserver) after applying the fix? Note that you also need to edit the classes again and just save the parameters again so they are correctly stored in the database. It is not required to change them but you need to resave them.
@Henry: Yes, I've restarted the whole box. After the fix, the array values are displayed fine - without escaped doublequotes - but the puppet agent still failed with the exception above.
- Related to Bug #23581: Upgrade to Foreman 1.17 converts YAML to JSON Hash added
I'm trying hard to reproduce this, but even complex hashes seem to be rendered properly. For example:
classes:
dhcp:
bootfiles:
override_value:
match: fqdn=server.example.com
value:
testvg:
physical_volumes:
- "/dev/sdb"
- "/dev/sdc"
logical_volumes:
test1:
size: 128M
mountpath: "/opt/test1"
test2:
size: 128M
mountpath: "/opt/test2"
test3:
size: 128M
mountpath: "/opt/test3"
test4:
size: 128M
mountpath: "/opt/test4"
test5:
size: 128M
mountpath: "/opt/test5"
I do see it now, with Arrays:
classes:
dhcp:
bootfiles:
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
name: foo
mount_point: "/bar"
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
name: john
mount_point: "/doe"
JSON.parse(@host.info.to_json).to_yaml(:line_width => -1)
- using this in hosts_controller, on the externalNodes method works well
- Status changed from New to Ready For Testing
- Assignee set to Daniel Lobato Garcia
- Pull request https://github.com/theforeman/foreman/pull/5769 added
- Related to deleted (Bug #23463: YAML rendering of external nodes generates incorrect data if hashes are used)
- Has duplicate Bug #23463: YAML rendering of external nodes generates incorrect data if hashes are used added
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
- Pull request https://github.com/theforeman/foreman/pull/5786 added
- Pull request https://github.com/theforeman/foreman/pull/5787 added
Also available in: Atom
PDF