Jira (PUP-4182) add a flag to get JSON output from puppet resource

2 views
Skip to first unread message

Daniel Dreier (JIRA)

unread,
Mar 11, 2015, 12:01:24 PM3/11/15
to puppe...@googlegroups.com
Daniel Dreier created an issue
 
Puppet / New Feature PUP-4182
add a flag to get JSON output from puppet resource
Issue Type: New Feature New Feature
Assignee: Unassigned
Created: 2015/03/11 9:00 AM
Priority: Normal Normal
Reporter: Daniel Dreier

As I discussed with Henrik Lindberg, I'd like an option to get JSON (and perhaps YAML) output from the puppet resource command. I can see two use cases:

1) For YAML, ability to go directly from existing puppet resources to YAML entries I can put into hiera to feed into create_resource
2) for JSON, as an extension point to use puppet in the context of shell scripts, python fabric scripts, etc. For example, using the puppetlabs-aws module, you could loop over the output of a puppet resource command listing all ec2_instances, use jq in bash (or python json parsing, etc) to select instances that lack appropriate tags, modify the JSON to add the appropriate tags, then feed that back into puppet apply to update the resources.

Ideally, I'd like some ability to pipe JSON into a puppet resource to set parameters, as well, but that's less important because I can use puppet functions in a puppet apply.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.3.10#6340-sha1:7ea293a)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Mar 11, 2015, 12:17:33 PM3/11/15
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Scrum Team: Language
Story Points: 3

Gareth Rushgrove (JIRA)

unread,
Mar 11, 2015, 12:25:28 PM3/11/15
to puppe...@googlegroups.com
Gareth Rushgrove commented on New Feature PUP-4182
 
Re: add a flag to get JSON output from puppet resource

Just a note that I'd love to see this too.

I think for managing environment/remote resources puppet resource is actually quite a killer feature. The AWS module is hugely improved by having a Puppet native command line interface. I would imagine other cloud-provider resources, and some of the other ideas like Kubernetes, Docker Swarm, Mesos Aurora/Marathon/Chronos, will see the same thing too.

Henrik Lindberg (JIRA)

unread,
Sep 7, 2016, 6:12:24 PM9/7/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Team: Puppet Developer Support
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Doug Rosser (JIRA)

unread,
May 17, 2017, 1:17:03 PM5/17/17
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

unread,
May 17, 2017, 1:20:03 PM5/17/17
to puppe...@googlegroups.com
Moses Mendoza commented on New Feature PUP-4182
 
Re: add a flag to get JSON output from puppet resource

`puppet resource` currently has a `--to_yaml` option that outputs resource in yaml.

Moses Mendoza (JIRA)

unread,
May 17, 2017, 1:20:03 PM5/17/17
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

unread,
May 17, 2017, 1:21:04 PM5/17/17
to puppe...@googlegroups.com
Moses Mendoza commented on New Feature PUP-4182

Daniel Dreier can you re-open if this doesn't work for you?

Gareth Rushgrove (JIRA)

unread,
May 17, 2017, 1:24:03 PM5/17/17
to puppe...@googlegroups.com

Note that this already works for YAML, ie.

puppet resource package --to_yaml

There are lots of oneliners for converting yaml to json as well:
http://www.commandlinefu.com/commands/view/12218/convert-yaml-to-json

Moses Mendoza (JIRA)

unread,
May 18, 2017, 1:55:18 PM5/18/17
to puppe...@googlegroups.com

Daniel Dreier (JIRA)

unread,
May 18, 2017, 1:56:16 PM5/18/17
to puppe...@googlegroups.com
Daniel Dreier commented on New Feature PUP-4182
 
Re: add a flag to get JSON output from puppet resource

The really compelling thing about JSON here is basically the jq CLI tool; I'm not aware of a similarly good tool for working with YAML. That said, I don't have an immediate use case for this so it's probably not worth prioritizing.

Jeremy Adams (JIRA)

unread,
Jan 29, 2018, 3:16:03 PM1/29/18
to puppe...@googlegroups.com
Jeremy Adams commented on New Feature PUP-4182

Larissa Lane FYI, we were wrestling with this earlier today, trying to get a list of ec2_instance resources with certain tags. Turns out that YAML output is somewhat broken and thus workarounds don't work. Also, modern tools are expected to have JSON output option.

https://tickets.puppetlabs.com/browse/PUP-7808

https://ask.puppet.com/question/4847/can-puppet-resource-user-answer-json/

This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Atlassian logo

Josh Cooper (JIRA)

unread,
May 18, 2018, 2:28:06 PM5/18/18
to puppe...@googlegroups.com
Josh Cooper commented on New Feature PUP-4182

We'll need to resolve the issue with structure data (PUP-7808) before adding JSON support.

This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (JIRA)

unread,
May 18, 2018, 2:28:06 PM5/18/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Team: Puppet Developer Experience Coremunity

Josh Cooper (JIRA)

unread,
Jul 6, 2018, 1:57:03 PM7/6/18
to puppe...@googlegroups.com
Josh Cooper commented on New Feature PUP-4182
 
Re: add a flag to get JSON output from puppet resource

I would really like to get JSON out of puppet resource

Josh Cooper (Jira)

unread,
Oct 19, 2022, 11:13:01 PM10/19/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Labels: Easy
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages