chef

what ruby features are used in chef recipes?

社会主义新天地 提交于 2019-12-02 02:50:55
I just started using chef and don't know much about ruby. I have problems understanding the language-syntax used in recipes. Say, I create a directory in a cookbook in recipes/default.rb like: directory "/home/test/mydir" do owner "test" mode "0755" action :create recursive true end I assume this is part of a valid ruby script. What do lines like owner "test" mean? Is this a function call, a variable assignment or something else entirely? Chef is written in Ruby and makes an extensive use of Ruby ability to design custom DSL. Almost every chef configuration file is written with a Ruby-based

Installing Chef Server on Windows

泄露秘密 提交于 2019-12-01 23:45:01
I'm trying to get a Chef Server up and running on a Windows 2008 Server box. I'm following the process here: http://wiki.opscode.com/display/chef/Installing+Chef+Server+Manually I've just installed Gecode and the next step is a ruby command: gem install chef-server chef-server-api chef-server chef-solr However, running this command gives the following output suggesting that Gecode isn't installed. C:\Users\Administrator>gem install chef-server chef-server-api chef-server chef- solr Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR:

SaltStack;以及与AnsibleWorks,Chef-solo,puppet等等等的比较!

喜夏-厌秋 提交于 2019-12-01 23:23:38
SaltStack;以及与AnsibleWorks,Chef-solo,puppet等等等的比较! ...        http://www.vpsee.com/2013/08/a-system-configuration-management-and-orchestration-tool-saltstack/ 系统自动化配置和管理工具 SaltStack 2013年08月22日 | 标签: devops , puppet , salt , saltstack | 作者: vpsee 我们的服务器 由 Puppet 配置管理工具来管理 ,服务器上线后由 puppet 完成初始化和配置等一系列工作(比如,静态 IP 配置,DNS 设置,NFS/SAN 挂载,LDAP/Kerberos 登录,安全加固配置,内核参数优化,防火墙规则配置等等),等初始化完成后开始运行,运行一段时间后有一些需要自动和手动操作的任务(比如升级、重启、备份等),这时候我们 使用 Fabric 来批量执行 这些临时任务。 所以从这里可以看到 Puppet 和 Fabric 其实是两个不同性质的工具,看下面的归类可能会更清楚一些。Puppet 和 Fabric 两个的工作其实可以由一个工具 SaltStack(或 AnsibleWorks)完成,减少一个工具的使用会减轻一点负担(学习工具的人力成本

Encrypt data bag from inside of ruby without relying on knife

落花浮王杯 提交于 2019-12-01 23:02:11
At the moment to encrypt a data bag, I have to do : system "knife data bag from file TemporaryEncrypting \"#{enc_file_path}\" --secret-file #{Secret_Key_Path}" and that doesn't work because knife can't find a config file and I can't seem to get it read the one in C:\chef . How do I do this from within ruby? I worked out how to encrypt inside of ruby, just use this code: require 'chef/knife' #require 'chef/encrypted_data_bag_item' #you need to do this in chef version 12, they've moved it out of knife and into it's own section require 'json' secret = Chef::EncryptedDataBagItem.load_secret Secret

How to set Node Attributes on a Chef Client?

寵の児 提交于 2019-12-01 21:21:42
I'm using the chef-client cookbook to configure a machine as a chef client . How do I configure node attributes when this client is created ? I do not want to do knife node edit . My aim is to set some node attributes when creating this node, probably by adding something to a JSON file. UPDATE: I am creating hundreds of nodes which will use this script ( see the gist ) to bootstrap chef-clients. Node_name which is in the script will be different for each node. Similarly I want to set a custom attribute to the node that will group them together. Say for example I want to group all the nodes

Chef: How do I check to see if a service is installed?

半腔热情 提交于 2019-12-01 17:37:26
In a recipe I want to check to see if a service is installed, and if it is not notify the 3 resources needed to install it. I tried the service resource, which correctly identifies the service when it is installed, but throws an exception if the service is not installed. I'm not sure what action to use here. :nothing just skips the resource so it ever get executed, but any of the other actions will error when they attempt to act on a service that doesn't exist. How do I detect whether a service is installed and act based on that information? I'm running on Windows, if that's relevant. Take a

Run the chef-client as non root user

烂漫一生 提交于 2019-12-01 11:26:42
I want to run the chef-client as a test user in my linux machine. For that, I add cache path in the client.rb file which is from /etc/chef/client.rb. cache_path "~/.chef/cache" Then I run the chef-client command from test user(non-root user).It shows error? Chef encountered an error attempting to create the client How to setup the cache-path? Is is necessary to move the client.rb,chef-validator.pem, client.pem, first-boot.json under test user? First of all, chef is intended to be run as root. A lot of resources assume they're run as root, and need it. They will fail if not running as root. For

Run all sql files with Chef

落花浮王杯 提交于 2019-12-01 10:58:45
Hello i need help i made a command that should read all the sql files inside of the sql_dumps folder but it isnt working.. here is what i got. execute "Run_SQL_Files" do dirResults = Dir.glob("/tmp/sql_dumps/*.sql") var = 0 while var < 15 do var = var + 1 command "mysql --user=root --password=toomba source" + dirResults[var] # Already tried this also # command "mysql --user=root --password=toomba < " dirResults[var] puts dirResults[var] end end I'am not very familiar with ruby. This is the error i received default: Errno::ENOENT default: ------------- default: No such file or directory - Run

Chef cookbook - reload PATH

心已入冬 提交于 2019-12-01 09:18:14
I just installed java using chef cookbook and updated PATH environment variable for all users (added new file to /etc/profile.d/). Is it possible to tell chef to reload PATH variable? When I do something like this: execute "java_check" do command "java -version" end Is says that java could not be found. It works fine when I log out, log in again and then run chef recipe. I'm not 100% sure you can update the PATH variable for future chef runs, but you can set it up manually using the environment attribute within the execute stanza. This can also be used on other Resources as well. See: http:/

Run the chef-client as non root user

拈花ヽ惹草 提交于 2019-12-01 08:04:49
问题 I want to run the chef-client as a test user in my linux machine. For that, I add cache path in the client.rb file which is from /etc/chef/client.rb. cache_path "~/.chef/cache" Then I run the chef-client command from test user(non-root user).It shows error? Chef encountered an error attempting to create the client How to setup the cache-path? Is is necessary to move the client.rb,chef-validator.pem, client.pem, first-boot.json under test user? 回答1: First of all, chef is intended to be run as