Project

General

Profile

Actions

Bug #1134

closed

Multiple host exporting formatting for rundeck not correct

Added by Marcello de Sousa over 12 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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)

Actions #1

Updated by Marcello de Sousa over 12 years ago

Links with the examples

YAML sequence (not working):
http://goo.gl/wgvt0

YAML map (working):
http://goo.gl/7RGZz

Actions #2

Updated by Marcello de Sousa over 12 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)
}

Actions #3

Updated by Ohad Levy over 12 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF