Bug #1134
closedMultiple host exporting formatting for rundeck not correct
Description
When rundeck reads it, we get:
java.lang.IllegalArgumentException: Required property 'nodename' was not specified
Currently Foreman is exporting multiple hosts to rundeck using this format (but it looks like the single "-" between each host makes the YAML be interpreted as a sequence, and should not be there) :
--- - puppet.perimeterusa.com: osVersion: "6.1" osName: RedHat username: Admin User osArch: x86_64 nodename: puppet.perimeterusa.com - test.perimeterusa.com: osVersion: "5.7" osName: RedHat username: Admin User osArch: x86_64 nodename: test.perimeterusa
This seems to work (with nothing in between):
--- puppet.perimeterusa.com: osVersion: "6.1" osName: RedHat username: Admin User osArch: x86_64 nodename: puppet.perimeterusa.com test.perimeterusa.com: osVersion: "5.7" osName: RedHat username: Admin User osArch: x86_64 nodename: test.perimeterusa
This also seems to work (with "---" in between):
--- puppet.perimeterusa.com: osVersion: "6.1" osName: RedHat username: Admin User osArch: x86_64 nodename: puppet.perimeterusa.com --- test.perimeterusa.com: osVersion: "5.7" osName: RedHat username: Admin User osArch: x86_64 nodename: test.perimeterusa
Other examples:
Current invalid export:
http://fpaste.org/OVr4/
Valid Examples:
http://fpaste.org/HpZA/
http://fpaste.org/OVr4/
According to ashp's chat history in #rundeck:
"...you have a sequence where you should have a map" (yaml related)
An that can be confirmed when I paste it in the website:
http://yaml-online-parser.appspot.com/
(select "canonical yaml" as output)
Updated by Marcello de Sousa over 13 years ago
Links with the examples
YAML sequence (not working):
http://goo.gl/wgvt0
YAML map (working):
http://goo.gl/7RGZz
Updated by Marcello de Sousa over 13 years ago
Fix by Ohad:
diff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb index c869d71..5969298 100644 --- a/app/controllers/hosts_controller.rb +++ b/app/controllers/hosts_controller.rb @@ -43,7 +43,9 @@ class HostsController < ApplicationController format.json { render :json => search.all(:select => "hosts.name", :include => included_associations).map(&:name) format.yaml do render :text => if params["rundeck"] - search.all(:include => included_associations).map(&:rundeck) + result = {} + search.all(:include => included_associations).each{|h| result.update(h.rundeck)} + result else search.all(:select => "hosts.name").map(&:name) }
Updated by Ohad Levy over 13 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
Applied in changeset 48e0b3a4ed6ae0174710689886b8140fee2bf3f1.