I am trying to programmatically pull existing environment json for a given environment name off chef server via an authenticated API GET request to /environments/NAME endpoint
knife exec getEnvjson.rb
getEnvjson.rb:
require “awesome_print”
env = api.get("/environments/STAGE")
ap env
exit 0
What I am getting back is just STAGE text value instead of the expected fully blown json definition of the STAGE environment.
Am I missing something?
Running 11.4.0 chef server, thinking whether this is a known issue that’s been addressed in the subsequent releases and I should upgrade?
What you get back is JSON with some magic hints such that Ruby turns it into a Chef::Environment object by default, which defines to_s to just return its name. You can either use it as a Ruby object, or use another client library that doesn't automatically inflate objects.
I am trying to programmatically pull existing environment json for a given environment name off chef server via an authenticated API GET request to /environments/NAME endpoint
knife exec getEnvjson.rb
getEnvjson.rb:
require "awesome_print"
env = api.get("/environments/STAGE")
ap env
exit 0
What I am getting back is just STAGE text value instead of the expected fully blown json definition of the STAGE environment.
Am I missing something?
Running 11.4.0 chef server, thinking whether this is a known issue that’s been addressed in the subsequent releases and I should upgrade?
-----Original Message-----
From: Noah Kantrowitz [mailto:noah@coderanger.net]
Sent: Friday, January 10, 2014 3:00 PM
To: chef@lists.opscode.com
Subject: [chef] Re: api.get(/environments/NAME) is not returning JSON
What you get back is JSON with some magic hints such that Ruby turns it into a Chef::Environment object by default, which defines to_s to just return its name. You can either use it as a Ruby object, or use another client library that doesn't automatically inflate objects.
I am trying to programmatically pull existing environment json for a given environment name off chef server via an authenticated API GET request to /environments/NAME endpoint
knife exec getEnvjson.rb
getEnvjson.rb:
require "awesome_print"
env = api.get("/environments/STAGE")
ap env
exit 0
What I am getting back is just STAGE text value instead of the expected fully blown json definition of the STAGE environment.
Am I missing something?
Running 11.4.0 chef server, thinking whether this is a known issue that's been addressed in the subsequent releases and I should upgrade?