Questions tagged [chef-infra]

Chef Infra (formerly just Chef) is a DevOps tool for scripting server configurations in Ruby (called cookbooks). Questions should pertain to the Ruby portions of coding. General DevOps questions may be asked on https://devops.stackexchange.com

Filter by
Sorted by
Tagged with
0 votes
0 answers
14 views

Cannot find a resource for user on chefspec version

I am newbie to cookbook. I got this issue, when I tried to create a user resouce. chef generate recipe thanh user # Chef::Exceptions::NoSuchResourceType: # Cannot find a resource for user on ...
0 votes
0 answers
13 views

Override Attributes are not working for my role

My cookbook does this: # attributes/default.rb default['fieldone']['fieldtwo'] = [ {'somekey' => 'val1', 'someotherkey' => 'vala'}, {'somekey' => 'val2', 'someotherkey' => 'valb'}, {'...
  • 26.5k
1 vote
0 answers
30 views

I tried creating a cookbook in chef but why this is showing this error?

I have installed chef in AWS EC2 instance. After installing I run the command chef generate cookbook test-cookbook and it is showing this error /opt/chef-workstation/embedded/bin/ruby: error while ...
0 votes
1 answer
19 views

Chef: Overriding a Parent's attributes in a cookbook

I am trying to understand how to override the attributes of a parent's cookbook. For example, let's say I have the following cookbooks\recipes: Parent -> attributes -> default.rb -> default['...
0 votes
2 answers
23 views

Chef cookbook - how to fetch hostname dynamically in the attribute file

I need to create 10 tomcat instances on 5 different servers (2 instances on each server). The instances names are common across the 5 servers. The Tomcat instances would need to be integrated with a ...
  • 1
0 votes
0 answers
113 views

ohai sub-attribute plugin load confusion

(chef 14.15.6 since 15 has the trapdoor license and I haven't moved to cinc) I have the following ohai module. It's my first, so don't expect it's perfect: # cookbooks/satellite/ohai/default.rb Ohai....
0 votes
0 answers
11 views

Kitchen list using Docker Desktop not launching

I'm trying to configure test kitchen using Docker Desktop but some how its not launching. kitchen list command just timed out. PS C:\chef-repo\cookbooks\apache> kitchen list C:/opscode/chef-...
0 votes
1 answer
43 views

Chef not_if/only_if command result and string comparison

I'm trying to run a command and compared its output but it appears my bellow code isn't working as I would expect it to. execute 'testcond' do command "echo success" only_if {"...
  • 1,188
0 votes
0 answers
31 views

How to include a module from another Cookbook's library?

I have the following setup: cookbooks/ cookbook1/libraries/prom.rb cookbook2/templates/default/execute.erb in prom.rb: module Prom class exporter # with several methods How can ...
  • 136
0 votes
0 answers
25 views

How to solve Error executing action `create` on resource 'file[myfile]'?

Getting below error while running chef in local \[9:37 am, 24/02/2023\] +91 78387 70136: FATAL: Stacktrace dumped to /Users/sonashar/.chef/local-mode-cache/cache/chef-stacktrace.out \[2023-02-24T09:21:...
0 votes
0 answers
191 views

knife ssl check fails wile connecting to manage chef.io

root@ip-172-31-9-21:/home/ubuntu/chef-repo# knife ssl check /opt/chef-workstation/embedded/lib/ruby/gems/3.1.0/gems/proxifier-1.0.3/lib/uri/socks.rb:8:in `<modu ...
0 votes
0 answers
36 views

Chef Test Kitchen fails to load ffi-yajl c-extention

Yesterday my system configuration was such that I could smoothly run kitchen test without issue. I don't know what happened, but this morning the configuration was all screwy and Kitchen wouldn't run. ...
0 votes
0 answers
43 views

How to get sorted files from remote directory in Chef?

I have a remote directory which has different types of files like .zip, .jar and .xml. Now I want to get the name of latest file from this directory which has .jar extension. The file names have date ...
0 votes
1 answer
43 views

Getting the last item in an array of hashes in my for loop in a Chef custom resource

I'm kind of stumped on this one... I am quite aware of the concept between the Chef run stage and compile stage but I still cannot seem to get what I need to accomplish figured out. I think the ...
0 votes
0 answers
42 views

OpsWorks and Chef recipes

I've been playing with AWS OpsWorks lately and I would just like to hear the opinion of someone with Chef programming experience about a recipe that I'm trying to run on Windows Server 2012. The ...
  • 1
0 votes
0 answers
55 views

While running the command chef-client -zr "recipe[twst-cookbook-test-recipe]" following warninng

While running the command chef-client -zr "recipe[twst-cookbook-test-recipe]" following warning shows? WARN: No config file found or specified on command line. Using command line options ...
0 votes
2 answers
33 views

Unable to log in to EC2 instance - for chef node creation

I am currently learning chef and AWS (new to both of them). I would like to create a node in https://manage.chef.io/organizations/su_cheflearning/nodes. The followings are the steps I have done: Go ...
  • 1
-2 votes
1 answer
29 views

mvn --version throws ClassNotFoundException

Through chef I have installed the maven in a amazonlinux2 instance. When I run the "mvn --version" command as a ec2-user I am getting proper output like below one but when I run the same ...
0 votes
0 answers
89 views

chef's Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '139' Error

So, when trying to enable ubuntu 22.04 on the chef client, when running the command : sudo chef-client --once -l info i get this error: ERROR: Running exception handlers Running handlers complete ...
1 vote
1 answer
128 views

Chef infra how to delete user?

I need a recet for the CHEF. How to delete users? So that when checking the VM list, there are no users. For example: cat /etc/group|grep john.deer john.deer:x:1043: To create new users, we use ...
  • 11
0 votes
0 answers
48 views

Chef knife is asking for password

I cannot use knife ssh through a jumphost without entering password manually. When using ssh command with same jumphost and same endpoint server all works well. This is the ssh command that works : C:\...
0 votes
0 answers
43 views

chef specification for yum-config-manager --add-repo

I use this command to download a repo config and install into /etc/yum.repos.d yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo I'd like to re-create that in a ...
0 votes
0 answers
43 views

After Chef Infra Server Upgrade cannot upload modified cookbooks

After upgrading to 15.3.2 (from 14.9.23) for the Chef Server, whenever I tried to upload a modified cookbook I get: WARN: Server returned error 503 for https://CHEFSERVERFQDN/organizations/ORGNAME/...
0 votes
0 answers
87 views

In Chef Inspec Ruby DSL, undefined method error when using a method defined earlier in the same file

I need to write several Chef Inspec controls that basically do the same checks but against different files and conditionally depending on certain factors (using the only_if syntax). I've written a ...
0 votes
0 answers
15 views

I want to enable 'Allowsignup' option by default in Jenkins

I have a groovy file that runs at the time of deployment to create predefined admin users for jenkins. I would like to add a logic here that would enable the allowsignup option. By default the option ...
1 vote
1 answer
116 views

How to write a Chef Inspec test for the Chef Infra 'sudo' resource?

Versions Chef Workstation version: 22.7.1006 Chef InSpec version: 4.56.20 Chef CLI version: 5.6.1 Chef Habitat version: 1.6.420 Test Kitchen version: 3.3.1 Cookstyle version: 7.32.1 Chef Infra Client ...
0 votes
0 answers
29 views

chef generate attribute cookbooks/base default error

I am following the course instructions on chef progress website to learn chef. Currently I am working through on collecting infra code by cloning an existing repo & creating the wrapper cookbook. ...
0 votes
0 answers
16 views

wkhtmltopdf install in opswork through Ruby for wkhtmltopdf_12.5.deb version

I want to install wkhtmltopdf(12.5).deb version in Ubuntu 18.04 but it is showing something like wkhtmltox not found. How can I automate my server for installation of wkhtmltopdf? I tried to install 0....
0 votes
0 answers
34 views

Chef builtin search method change

I use the AWS-ApplyChefRecipes document in SSM to run Chef cookbooks against my instances and manage the users, SSH keys, and sudo permissions for each instance based on tags. AWS on October 7 appear ...
0 votes
0 answers
38 views

Chef Client Upgrade 16 => 17 Kitchen Converge Failure SSL Verification

Business is working on upgrading chef client throughout the orgs from 16 to 17 (17.9.26 specifically). Within our cookbooks we perform a chef http_request to test the availability of the resource ...
0 votes
1 answer
32 views

undefined method `chef_gem' for #<Chef::Node::Attribute:0x000055cb839ecd58>

so i'm trying to extract some values from vault in my attributes file. And the first few lines of code are the following: chef_gem 'vault' do compile_time true end require 'vault' Vault....
0 votes
0 answers
24 views

Chef Inspec - How to use describe input('bbb') inside describe command('aaa')

The below code is throwing error stating : expected : "2:30:30 AM" got: #<RSpec::Core::Example "NextRunTime"> describe command("Get-ScheduledTaskInfo 'Restart'") do ...
0 votes
2 answers
64 views

Chef - Custom Resource - How to notify only if the content of the ressource updates a file?

I'm not sure if I've understood the concept of notifying other resources based on a custom resource correctly. I have a resource: get_api_calls 'www.myapi.com' do request '<myrequest>' ...
0 votes
0 answers
142 views

Ruby (Chef) Hash Array - Name is a Required Property

I'm trying to create a recipe to deploy Remote Desktop Services to Windows Servers, everything is working as expected apart from the Application deployment resource I created - it's a simple resource ...
0 votes
1 answer
112 views

Chef Recipe - check if kernel version is at a certain level or greater

I have a line in my recipe which needs to run if the client is at a certain kernel version or greater. ie: if platform_family?('rhel') && node['platform_version'].to_i == 5 && node['...
  • 111
1 vote
1 answer
136 views

Ruby (Chef) Unable to pass a hash array into a Chef resource

I'm trying to create a recipe to deploy Remote Desktop Services to Windows Servers, everything is working as expected apart from the Application deployment resource I created - it's a simple resource ...
0 votes
0 answers
44 views

How to Run Test Kitchen on Cookbooks Directly from Chef Infra Server

I need to run the Chef Kitchen test directly from Chef Infra server without maintaining the cookbook locally. Is there a way we can configure Kitchen test to get the cookbook directly from Chef Infra ...
0 votes
1 answer
74 views

How do I create a cron job via a chef receipe using the cron resource?

I have the following in the cron.rb file. cookbook 'cron', '~> 7.0.4', :supermarket cron 'Check-In to Chef Manage' do minute '*/2' command 'chef-client' end I've verified that the recipe ...
0 votes
2 answers
146 views

How to access GitLab CI/CD Variable in Ruby Recipes?

I have declared some variables in Gitlab -> Settings -> CI/CD -> Variables. I want to access these variables in ruby (.rb) files for chef cookbook recipes. I have declared a variable named &...
1 vote
1 answer
48 views

Accessing Chef::Config during chefspec run / variables outside action

Say I have this spec file: require 'chefspec' describe 'dummy::dummy' do step_into 'dummy_dummy' platform 'ubuntu' context 'creates directory' do recipe do dummy_dummy 'foo' end ...
  • 1,586
1 vote
1 answer
208 views

chef recipe compile error as "undefined method 'cwd' for cookbook"

I have a chef recipe to iterate multi module from json array. Here i have defined the cwd from the json node attribute, but it is getting failed with the chef recipe compile error as "undefined ...
  • 15
0 votes
0 answers
17 views

Moving on from knife-solo

I've inherited our knife VM for the purpose of cooking our servers. The VM uses knife-solo 0.7.0. The cook commands work fine as far as we can tell to maintain our current servers, but when we attempt ...
0 votes
0 answers
59 views

chef-workstation: permission denied errors while performing chef spec test

We just started using chef-workstation ( https://www.chef.io/downloads/tools/workstation ). In our scenario, For example one of the user (USERA) tried to perform (rspec) "chefspec test" on ...
0 votes
1 answer
123 views

How to iterate json array from role.json is role to chef recipe

I have a role_multi_module.json which is a chef role which contains a array in JSON format. Role name: role_multi_module.json { "name": "role_multi_module", "...
  • 15
0 votes
1 answer
39 views

Check for installed RPM

In my cookbook I have: unless app_rpm.nil? node.default['app_rpms'] = \ %w(agent1 agent2 agen3 agent4) node['app_rpms'].each do |rpm_package| package rpm_package do action :remove ...
0 votes
0 answers
27 views

SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: (null) when communicating with Chef Automate server

I am having difficulty connecting to my Chef Automate server, hosted on AWS OpsWorks. I am usually connecting to it at least once per day, however since the start of the week I have been unable to. ...
  • 16.3k
1 vote
1 answer
61 views

Chef powershell_script guard throws false when throwing an exception

I have a chef powershell_script which seems to be running whenever the not_if guard throws an exception, I would like to change it so that the chef run fails when the not_if throws an exception, would ...
1 vote
0 answers
29 views

Knife command output in human readable format

So I am trying to get filesystem sizes using a knife command as below. As is, I can see the sizes in kb; is there a way I can convert them to human readable values (Mb or Gb) in knife commands itself? ...
  • 236
0 votes
0 answers
71 views

Kitchen private network (Argumenterror)

In the kitchen.yml does not work the following -['private_network', { type: '192.168.4.3'} ] Whenever I use kitchen-converge the following error message appears >>>>>> ------...
0 votes
0 answers
67 views

Verify Nginx conf file with chef inspec

I am new in using chef Inspec. I wanted to test so off the options and I decided to test a auto deploy of nginx with verification test on a personal server . So I wanted to test worker_connections ...

1
2 3 4 5
130