Jira (BOLT-1223) Type information not available in plans.

3 views
Skip to first unread message

Alex Dreyer (JIRA)

unread,
Apr 4, 2019, 2:39:04 PM4/4/19
to puppe...@googlegroups.com
Alex Dreyer updated an issue
 
Puppet Task Runner / Bug BOLT-1223
Type information not available in plans.
Change By: Alex Dreyer
Summary: Inconsistencies Type information not available in Result outputs vs access methods plans.
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Alex Dreyer (JIRA)

unread,
Apr 4, 2019, 2:42:02 PM4/4/19
to puppe...@googlegroups.com
Alex Dreyer updated an issue
There are major inconsistencies in how views a Result output vs how one accesses it. For example, running this command

The use of { code}
run_command('mkdir ~/boltexamples', $nodes).each | $result |
{
    notice($result)
type }
{code
}

Provides me with a json hash output that looks easy
to navigate (after piping through | python -mjson.tool:

{code:json}
{
    "node": "puppet.c.splunk-217321.internal",
    "object": "mkdir ~/boltexamples",
    "result": {
        "exit_code": 0,
        "stderr": "",
        "stdout": ""
    },
    "status": "success",
    "
refer to the type ": "command"
}
{code}

Now looking at this
of action that created a result , I would assume I could access the node name, object , result, and status just by referring is unable to be exposed as an attribute on the hash keys, result object since that's what I'm looking at. Assuming I've not yet dove into the docs and I'm just reading existing code and want to poke around, I may go and do this:

{ code}
run_command('mkdir ~/boltexamples', $nodes).each | $result |
{
    notice($result['node'])
type }
{code
}

Which
is frustrating because the output I get is:

{code}
Starting: command 'mkdir ~/boltexamples' on puppet.c.splunk-217321.internal
Finished: command 'mkdir ~/boltexamples' with 0 failures
used elsewhere in 2 Puppet . 28 sec

Finished Possible solutions : plan firstproject::firstplan in 5.1 sec
Plan completed successfully with no result
{code}

So I guess that's an empty hash? How do I actually access these variables? Now I have to go to the documentation to see what is what - which explains that I can access those as functions, but function names have no correllation to what I was just looking at, in fact we hide the mapping in the code here:

https://github
1 . com/puppetlabs/bolt/blob/master/lib/bolt/result.rb#L93-L99

Ah, now I see if I want the node name, I have
Rename this key to call $result.target.name - otherwise I just get the result of
{ code}
Target('puppet.c.splunk-217321.internal',
{ "user"=>"cbarker" action } )
{code
}
Bonus surprise: I'd think I could get away
and expose it with `$result a method . type` to see what type of function this was, but instead, I get the ruby definition of the object:

2. Add a { code}
Object[
{ name => 'Result', attributes => {'value' => Hash[String[1], Data], 'target' => Target to_data } , functions => {'error' => Callable[[0, 0], Optional[Error]], 'message' => Callable[[0, 0], Optional[String]], 'ok' => Callable[[0, 0], Boolean], '[]' => Callable[[String[1]], Data] } }]
{code}

Making the onscreen output of Bolt be logically consistent with methods
method to call and extract the Result object that data will be essential for new users to learn how to access and work with it. If we're going to to have `notice($result)` output returns a hash , I should be able equivalent to access the subhash without having to read the docs json output . So far I have yet to be able to access This will make the equivalent of `$result["object"]` or `$result["type"]` even though that would be usecase which triggered the logical way I could access it while looking at initial ticket, the output of the code. I can't tell if it is just undocumented or a bug or a mixture of both.

Edit:
ability to clarify, I don't know how to get pass the contents of object or type at all from this result , can't seem from one action directly to find an example of how I could load it in a plan anywhere, regardless of invocation method task easier . This may or may not include renaming type.

Alex Dreyer (JIRA)

unread,
Apr 4, 2019, 2:43:02 PM4/4/19
to puppe...@googlegroups.com
Alex Dreyer updated an issue
Change By: Alex Dreyer
Sprint: Bolt Ready for Grooming

David Kramer (JIRA)

unread,
Apr 16, 2019, 12:30:03 PM4/16/19
to puppe...@googlegroups.com
David Kramer updated an issue
Change By: David Kramer
Sprint: Bolt Ready for Grooming Kanban

Alex Dreyer (JIRA)

unread,
Apr 16, 2019, 12:32:03 PM4/16/19
to puppe...@googlegroups.com
Alex Dreyer updated an issue
Change By: Alex Dreyer
The use of {{type}} to refer to the type of action that created a result object is unable to be exposed as an attribute on the result object since {{type}} is used elsewhere in Puppet.

Possible solutions Solution :
1. Rename this key to {{action}} and expose it with a method
, the values should remain the same .
2. Add a {{to_data}} method to
the Result object all bolt datatypes that returns return a hash or array equivalent to the of their json output. This will make the usecase which triggered the initial ticket, the ability to pass the result from one action directly to a task easier. This may or may not include renaming type.

Alex Dreyer (JIRA)

unread,
Apr 16, 2019, 12:33:03 PM4/16/19
to puppe...@googlegroups.com
Alex Dreyer updated an issue
The use of {{type}} to refer to the type of action that created a result object is unable to be exposed as an attribute on the result object since {{type}} is used elsewhere in Puppet.

Solution:
1. Rename this key to {{action}} and expose it with a method, the values should remain the same.
2. Add a {{to_data}} method to all bolt datatypes that return a hash or array equivalent of their json output. This will make the usecase which triggered the initial ticket, the ability to pass the result from one action directly to a task easier. This may or may not include renaming type.


Note the "target" in a Result should be the name not the full target hash. Adding to_data to Target is out of scope

Cas Donoghue (JIRA)

unread,
Apr 30, 2019, 2:58:02 PM4/30/19
to puppe...@googlegroups.com

Cas Donoghue (JIRA)

unread,
May 1, 2019, 6:10:03 PM5/1/19
to puppe...@googlegroups.com

Cas Donoghue (JIRA)

unread,
May 6, 2019, 1:22:08 PM5/6/19
to puppe...@googlegroups.com
Cas Donoghue updated an issue
Change By: Cas Donoghue
Fix Version/s: BOLT Next

Cas Donoghue (JIRA)

unread,
May 6, 2019, 1:26:03 PM5/6/19
to puppe...@googlegroups.com
Cas Donoghue updated an issue
Change By: Cas Donoghue
Release Notes Summary: A new `to_data` method is available for plan result objects that provide a hash representation of the object.
Release Notes: New Feature

Melissa Amos (JIRA)

unread,
May 13, 2019, 4:46:04 PM5/13/19
to puppe...@googlegroups.com
Melissa Amos updated an issue
Change By: Melissa Amos
Labels: docs docs_reviewed
Reply all
Reply to author
Forward
0 new messages