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
8,185
questions
1
vote
0answers
18 views
Why nohup on execute resource doesn't work - Chef recipe
I'm trying to deploy a django app (dev mode) using chef. The problem is, when execute the recipe the server doesn't kept alive.The command works when I log in, but because it doesn't change the ...
0
votes
1answer
7 views
How can I find/collect license information for our cookbook dependencies in Chef?
We use Chef 12.x-16.x. Is there a simple way to collect license information for all the packages we dependent on (directly and indirectly)? We get all our dependencies from Supermarket.
In the npm ...
0
votes
0answers
11 views
Ruby NTLMv2 authentication issue
I am trying to eliminate NTLMv1 authentication completely and go with NTLMv2 authentication for my ruby application (Chef). Since I could not find an easy to use native ruby library with NTLMv2 ...
0
votes
1answer
19 views
InSpec Kubernetes Resource Pack Ruby error
trying to get started testing kubernetes with inspec using: https://github.com/bgeesaman/inspec-k8s
Im running it from the make and docker image found here: https://github.com/bgeesaman/inspec-k8s-...
0
votes
1answer
32 views
How can I access variables inside a not_if in chef
I'm new to chef so I might be doing something really wrong here. The question is, how do I access the LOG_DIR in the ruby block. I want to use LOG_DIR in quite a few places in my recipe.
LOG_DIR = &...
1
vote
0answers
15 views
Using Chef Inspec is it possible to verify the strength of SSH keys?
On executing the command ssh-keygen -lf /etc/ssh/ssh_host_dsa_key.pub I am getting a output where the first few digits represent the key strength. Is there a possible way to validate the key strength ...
0
votes
1answer
17 views
chef inspec validation of the nested json file
I am using chef inspec to validate in the below json file whether annotation is equal to Test.
"imdata": [
{
"aaaPwdStrengthProfile": {
"attributes&...
0
votes
0answers
10 views
Better way to install Xcode onto AMIs via Packer
I am looking for ways to install Xcode onto the new mac Catalina AMIs. I am writing my own script to use xcversion to install, but I want to consider other avenues before I go too deep. Thinking maybe ...
1
vote
1answer
24 views
No attribute precedence across different attribute sources?
I'am aware of the attribute precedence and i'am also aware about the different attribute sources
What i really cannot wrap my had arround (for a long time now) how precedence is across sources. When ...
0
votes
0answers
13 views
ChefSpec: When do you need a SoloRunner?
In which situations do you need a SoloRunner or ServerRunner in Chefspec?
require 'spec_helper'
describe 'recipe::test' do
context 'When all attributes are default, on an unspecified platform' do
...
0
votes
0answers
29 views
chef recipe to check the count of processes and monitor the number of open file descriptors
I am trying to update the metricbeat_cookbook to get some required info.
Monitor the number of Number of sessions and html5 client processes running each server. ps -ef | grep -i html5 | wc -l. This ...
1
vote
1answer
15 views
Running commands on all/specific chef nodes in parallel
My development ,staging and production servers (webapps, webservers, databases and some other services) are provisioned and configured with chef infra and connected to chef-server.
I want to ssh and ...
0
votes
0answers
14 views
how to check if chef template file exist or not with any particular name?
how to check if chef template file exist or not with any particular name?
I have some config file for dedicated servers. I want to deploy those config on matching server name.
0
votes
0answers
14 views
regex function in chef inspec output
I am using chef inspec for the postgressql.
I am executing the below command to match the output "local0". Because the output can be local0 or local1 etc. so given % to match any number ...
0
votes
0answers
25 views
Enable and Disable Chef client
How does one disbale chef-client and the reverse of that, to re-eanble it?
recipe[syseng::site_server] (syseng@tradingtechnologies.com)
Platform: centos 7.6.1810
Data Center: mock-chicago
...
0
votes
1answer
26 views
Is there a syntax to remove the \n from the chef inspec output
When executing the below command:
describe sql.query("show pgaudit.log;") do
its("output") { should match 'ERROR: unrecognized configuration parameter "pgaudit.log"'...
0
votes
1answer
18 views
Adding node to the chef server
I am trying to add node having windows 10 as OS using knife bootstrap -o winrm 192.168.0.122 -x Administrator -p '' --node-name node1
But it is throwing a warning Failed to authenticate Administrator ...
0
votes
1answer
31 views
load_current_value when there are no properties
Let's say I have this very simple custom chef resource:
property :path, String, name_property: true
action :create_if_missing do
file "#{new_resource.path}" do
content ''
end
end
...
0
votes
0answers
12 views
Chef test-kitchen asks sudo password but cant define
Im trying to deploy the test-kitchen and run my chef recepies on it. Im using the vcenter driver.
Everything works until the transport dont want to install my things. It requires sudo, but I dont know ...
1
vote
3answers
48 views
Is it possible to access the run_status object when using Chef.event_handler?
I have a bit of a catch-22 that I can't seem to find a solution for. I can successfully do this:
#
# Cookbook:: core_unix_base_cmcb
# Recipe:: email_on_fail
email_hash = node.default['...
0
votes
0answers
32 views
can not believe this: chef lazy block get executed 3 times
I can not believe this! I ran into a chef issue: file content lazy ruby block gets executed 3 times, but it is supposed to be only run once.
$ sudo cat /var/chef/cache/cookbooks/infra-tmp/recipes/...
0
votes
2answers
58 views
Chef - Prevent multiple service restarts or reloads with dnmsasq?
How does one get to a single restart/reload on a single chef run and be within chef best practices?
Is using a status file a good practice or re-writing the service dnsmasq information?
This question ...
1
vote
1answer
27 views
Test Kitchen Chef Zero Use Sudo to create root_path
I'm trying to match Chef zero with what's actually used on my Chef server by setting the root_path to /etc/chef from the default /tmp/kitchen. After Chef is installed I get the following error:
...
0
votes
0answers
24 views
Chef get all roles on the Chef server during a cookbook converge
I have a recipe which uses Chef roles to create subscriptions. Nodes with role a subscribe to checks that are tagged to a subscribers. I need to remove a subset of the subscribers from a check.
Is ...
0
votes
1answer
25 views
chef locale resource does not apply properties
i am using chef version 16.9.20 and utilizing the locale resource as follows
locale 'set system locale' do
lang 'en_US.UTF-8'
end
i see that it is executed on chef-client run
* locale[set system ...
0
votes
2answers
34 views
chef-client 16 does not report how many resources got updated
I am using chef-client 16.8 on Ubuntu Focal,
just found that its output is quite different with previous one,
# chef-client -o some_cookbook -l info
...
[2021-01-14T09:45:49+00:00] INFO: Skipping ...
1
vote
1answer
24 views
Delete files older than last 14 days in windows IIS server
I want to write a recipe in Chef to delete all files mentioned in C:\inetpub\logs\LogFiles\W3SVC1 which are older than 14 days.
So at any given day I should not have files older than 2 weeks.
Dir['C:\...
0
votes
1answer
27 views
Invalid argument for Chef Directory Resource? Any Ideas why
So, I have the following code which is a ruby block that opens a file on disk and reads each line. Each line is a string that is a dataversion (example: "2020_Q1_NA")
I am reading the file ...
0
votes
1answer
25 views
How to pass variables in Chef recipe
I'm wondering how I can manage this with Chef and variables.
I have my default section with the following variable
node.default['common']['docker'] = "18.09.1"
So, I want to manage the ...
0
votes
1answer
27 views
No such cookbook exception in Chef even if cookbook is available and dependency is set - AWS OpsWorks
I am a beginner in Chef and AWS OpsWorks. I was trying to experiment with custom recipes. I created a git repository having a directory test_cookbook, and configured chef to get cookbooks from it. ...
1
vote
0answers
54 views
Unable to connect from chef-client to chef-server using packer chef-client provisioner
I have been trying to install chef-client using packer in azure vm windows 2016 datacenter image but after creating image i checked in chef workstation that the image with chef-client configuration ...
0
votes
1answer
15 views
Validate database output using chef inspec
While executing the below postgresql command, how to validate the output under name column and row column using chef inspec.
postgres=# select name, setting from pg_settings where (name ~ '_directory$'...
0
votes
1answer
26 views
ERROR: Report handler Chef::Handler::AuditReport raised #<ArgumentError: comparison of Float with String failed>
I am running audit cookbook for rhel8 server . Desired profiles are available in automate server . However chef-client ends with below error :
Running handlers:
[2021-01-05T11:08:56+01:00] ERROR: ...
1
vote
1answer
52 views
How to use Library Methods from another cookbook in chef?
I have a case where I have to use a library function from another cookbook, but I am always getting had an error: NoMethodError: undefined method 'func'.
What did I try:
cookbook_1/libraries/lib1.rb:
...
0
votes
1answer
28 views
What is the difference of term “Chef Infra Client” and “Chef Client”
Just a quick question as the title.
The term "Chef Infra Client" seems suddenly popped up recently without any exclamation of whether it is just a name changed from "Chef Client".
0
votes
0answers
53 views
Passwordless chef client bootstrapping
I am bit familiar with Chef and its bootstrapping techniques. I am trying to bootstrap my new chef-client/node without passing password
I tried below by generating a ssh key but still failing
knife ...
0
votes
1answer
31 views
Is it possible to make a Custom Library Module aware of Cookbook Attributes in Chef?
I have a helper module which aids in working with a database. The helper module has been created as a custom DSL as per https://docs.chef.io/custom_resources/#custom-resource-dsl. I use the helper ...
0
votes
0answers
15 views
Ident authentication failed for user using Chef Inspec for PostgreSQL
While executing the below chef inspec audit for postgresql database, getting error. please advise.
sql = postgres_session('myuser', 'mypass')
describe sql.query('SELECT * FROM pg_shadow WHERE passwd ...
0
votes
0answers
26 views
Chef is now asking for a password instead of using the key provided to configure EC2 server
We use little chef to adjust server configuration. I'm not sure if this got updated on my system recently or something but for some reason it is now asking me for a password when I run the command
...
0
votes
0answers
27 views
Chef Failure : FATAL: LoadError: Could not open library 'archive': archive: cannot open shared object file:
Hi I am working on upgrading to linux ami2 and I am coming across an issue when I am running the kitchen converge in chef, I am getting the following error Could not open library 'libarchive.so': /...
0
votes
1answer
23 views
mystery: chef-client/knife: they are ignoring any error in knife.rb and client.rb
I happened find that in ~/.chef/knife.rb or /etc/chef/client.rb,
any error will be ignored by knife or chef-client.
...
a_non_exist_method a_non_exist_var
...
puts "==== #{a_non_exist_method}&...
0
votes
0answers
6 views
Why does my Chef Workstation say “chef-vendor-mysql”?
I'm trying to learn chef and install mysql through this guide and around the time I tried installing mysql 8.6.0 my console suddenly changed to this: . What is that field referred to and why did it ...
0
votes
1answer
31 views
Execute instructions in chef recipes only for Test Kitchen converge action
I need a way to run parts of chef recipes only in case of converge action in Test Kitchen.
I found a way to do it for ChefSpec:
unless defined?(ChefSpec)
cookbook_file "/home/#{node['user']}/...
0
votes
1answer
34 views
Chef Client failed without errors
I've run chef for existing cookbook, however I can't run it correctly.
I've got Chef Client failed without any error.
1
vote
2answers
48 views
Can I use sort and uniq on an array of chef node attributes?
We have a template that generates a bash script, that includes a list of patches to check for based on node attributes - specifically the role assigned to the node.
patchlist=( <%= node['oracledb'][...
-1
votes
1answer
24 views
Chef Cookbook Recipe action to agree end user License agreement and automate an Installation process
I am a newbie to chef, need some inputs on writing a recipe for allowing the actions that needs user input like "Press 1 to continue", "2 to quit", "3 to redisplay" else ...
0
votes
2answers
38 views
How to write multiple iptables rules in chef?
I was trying to write multiple iptables for blocking certain subnets and it turns out that the very last iptables rule is only getting implemented. This is what I've put in the recipe:
execute "...
1
vote
1answer
20 views
chef execute resource does not working on Rhel 8
I am using execute resource in cookbook recipe. the recipe is working normaly while recipe calling on cli. the recipe does not working schedule with cron. i send error log below;
* execute[DNS ...
1
vote
0answers
38 views
List properties of a resource
I'm implementing a custom resource which is basically a facade to an existing resource (in the example below its the vault_certificate resource).
Using the existing resource this code is valid:
...
0
votes
1answer
25 views
How to specify cookbook dependencies based on OS?
I am trying to find the best way of managing dependencies which are not available for all OS platforms. Our cookbook is cross-platform, it is aimed at both Linux and Windows systems. One of our recent ...