13: # Unless required by applicable law or agreed to in writing, software
14: # distributed under the License is distributed on an “AS IS” BASIS,
15: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: # See the License for the specific language governing permissions and
17: # limitations under the License.
18: #
19:
20>> if node[‘splunk’][‘disabled’]
21: include_recipe ‘chef-splunk::disabled’
22: Chef::Log.debug(‘Splunk is disabled on this node.’)
23: return
24: end
25:
26: if node[‘splunk’][‘is_server’]
27: include_recipe ‘chef-splunk::server’
28: else
29: include_recipe ‘chef-splunk::client’
I have checked the chef-splunk cookbook and it seems to be missing an initial value for the node[‘splunk’][‘disabled’] node object.
You can fix this by defining it in a environment json or by modifying the cookbook attribute file.
Thanks Mark, i’ve defined: the below statement in the default.rb in the recipe folder and still did not work, is that you mean on first response appreciate any help.
Are you running the code in chef-server <-> chef-client style or executing it in locally with chef-solo?
Either way you could create a small json file ./my_environment.json with the contents of
{
"splunk": {
"disabled": false
}
}
and pass in a --json-attributes ./my_environment.json to the executable. This way you would have node[‘splunk’][‘disabled’] defined without touching and modifying the original code.
Thanks Mark appreciate that, this what i did: i’ve created a jason file: and placed it in the environment folder with the content below:
{
“splunk”: {
“disabled”: false
}
}
and modified the default.rb with the code below: Everything got uploaded to the chef-server however when i try to upload the sample.json i will i get the following error: ERROR: . failed to create_child: Failure creating ‘sample.json’: 400 “Bad Request” cause: {“error”:[“Invalid key splunk in request body”]} any ideas?