chef

Add a new role to a Chef .json file with Sed

懵懂的女人 提交于 2019-12-07 06:31:25
I have a typical .json file for Chef e.g. servername.json { "name": "myserver123", "chef_environment": "test", "run_list": [ "role[base-pkg]", "role[interesting_stuff]", "role[user_apps]" ] } What I would like to do is use a "one liner" to add a new role after the last role found in the file. Since I never know what roles or how many are in a file i thought to search for the final closing "]" bracket and add the new role above that. I tried the following: tac servername.json | sed -i '0,/\]/a "role[My_New_Role]"' thinking that this would find the (now) first "]" and add the new line after it.

How can I test my LWRP with ChefSpec?

匆匆过客 提交于 2019-12-07 04:39:23
问题 I created my custom LWRP, but when I run the ChefSpec units test. It doesn't know my LWRP actions. Here is my resource : actions :install, :uninstall default_action :install attribute :version, :kind_of => String attribute :options, :kind_of => String Here is my provider : def whyrun_supported? true end action :install do version = @new_resource.version options = @new_resource.options e = execute "sudo apt-get install postgresql-#{version} #{options}" @new_resource.updated_by_last_action(e

cannot load such file — ruby-wmi (LoadError) & cannot load such file — win32/service (LoadError)

懵懂的女人 提交于 2019-12-07 01:07:27
问题 I did install below mentioned ruby stuff when i try executing chef-client, i receive below mentioned error c:\RubyDevKit>chef-client C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- ruby-wmi (LoadError) from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-10.14.4/lib/chef/provider/env/windows.rb:20:in `<top (required)>' from C:/Ruby193/lib/ruby/site_ruby/1.9.1

Chef: Installing a Windows Service

為{幸葍}努か 提交于 2019-12-06 16:21:04
I'm new to this forum (so apologies if I've posted in the wrong place) and also VERY NEW to Chef. I've been all around the houses trying to get a clear example of how to install a Windows service. Basically I want the Chef equivalent of "SC create" The recipe I'm trying to use is this: windows_package "RMS_EU" do installer_type :msi action :install source "c:\Servies\V5.5\EUNTRouteManager\Routing.WindowsService.exe" end When I run this I get error saying theres a problem with msi. I've tried multiple variants of this script and am finding getting clear information on how to install a simple

How to upload a WAR file on Tomcat 7 cookbook by Chef?

↘锁芯ラ 提交于 2019-12-06 14:33:10
I'm trying deploy a War file on my Tomcat 7 installed by a cookbook on CHEF. But, I can't find a single answer for my question at any forums. I don't have any idea how to do this! I'm using a Ubuntu server 12.10. The recipe that I'm using is https://github.com/solarvm/tomcat7-cookbook Stephen C The simple way to do is is to use the service resource to stop Tomcat, use the bash resource or a file resource to copy the WAR file, and then use the service resource to start Tomcat again. That cookbook you are trying to use doesn't do WAR file deployment. But I found this one - https://github.com

How to setup Vagrant ssh agent forwarding?

泪湿孤枕 提交于 2019-12-06 13:29:31
My goal is to connect from a VirtualBox VM to another machine using the ssh key authentication. I have created the VM with Vagrant (1.0.5). I have also enabled config.ssh.forward_agent = true (as suggested in this post ). Sadly, the ssh forwarding does not seem to be working. These are the steps (on fresh ubuntu with vagrant and virtualbox): Log from the host machine to VM (when I use --debug, I see that the forwarding is enabled) vagrant ssh Log from VM (ubuntu 12.04 with injected vagrant ssh key) to external machine ssh -A sk@192.168.0.1 to get: Permission denied. Do I need to perform any

How to pass Chef data bag secret to a docker container?

眉间皱痕 提交于 2019-12-06 13:18:50
问题 I have already created a databag item which is existing on the chef server. Now, I am trying to pass on that databag item secret value to a docker container. I am creating the data bag as follows: knife data bag create bag_secrets bag_masterkey --secret-file C:\path\data_bag_secret I am retrieving value of that databag item in Chef recipe as follows: secret = Chef::EncryptedDataBagItem.load_secret("#{node['secret']}") masterkey = Chef::EncryptedDataBagItem.load("databag_secrets", "databag

Chef in local mode cookbooks only

匆匆过客 提交于 2019-12-06 12:18:52
问题 I'm trying to set up a workflow to develop Chef cookbooks locally. We're currently using Chef Server with the provisioned nodes using chef-client. As part of the new workflow, we want to be able to start using Vagrant to test cookbooks locally to avoid incurring in the costs of testing on a remote machine in a cloud. I'm able to launch and provision a local Vagrant machine, but the one thing I'm not really sure how to do is to have Chef load the local version of the cookbook, but still talk

cookbook_name in recipe- TypeError: no implicit conversion of Symbol into String

戏子无情 提交于 2019-12-06 10:09:59
I have the following code in my recipe but it errors. log "###" + cookbook_name + "::" + recipe_name + " " + Time.now.inspect + ": Starting execution phase" puts "###" + cookbook_name + "::" + recipe_name + " " + Time.now.inspect + ": Starting compile phase" The error is: TypeError: no implicit conversion of Symbol into String /test/chef/cookbooks/cookbook-server/recipes/setup_server.rb:10:in `+' The issue seems to be with the cookbook_name , recipe_name etc.(the ones which are not hardcoded). Please help. When you're doing + action with the strings in Ruby, it doesn't convert other types to

Using attributes in Chef Solo JSON

半世苍凉 提交于 2019-12-06 10:04:43
问题 Is it possible to specify attribute values in Chef Solo's JSON? I have a solo.json with a run list and I would like to specify the attributes there. The Chef documentation seems to indicate it should be possible for me to do something like: { "hostname": { "test": "value2" }, "default_attributes": { "hostname": { "test": "value3" } }, "override_attributes": { "hostname": { "test": "value4" } }, "default": { "hostname": { "test": "value5" } }, "run_list": [ "recipe[hostname::default]" ] }