chef

chef 11: any way to turn attributes into a ruby hash?

笑着哭i 提交于 2019-12-05 03:32:36
I'm generating a config for my service in chef attributes. However, at some point, I need to turn the attribute mash into a simple ruby hash. This used to work fine in Chef 10: node.myapp.config.to_hash However, starting with Chef 11, this does not work. Only the top-level of the attribute is converted to a hash, with then nested values remaining immutable mash objects. Modifying them leads to errors like this: Chef::Exceptions::ImmutableAttributeModification ------------------------------------------------ Node attributes are read-only when you do not specify which precedence level to set. To

How can I set the log output level for Chef on Amazon OpsWorks?

风流意气都作罢 提交于 2019-12-05 02:37:41
问题 My question is similar to: How can I display the output of a Opscode Chef bash command in my console? I want to be able to see console output for my running recipe. In particular, my recipe failed to start JBoss because JAVA_HOME was not being set. It took me an entire day to figure this out because the statement JAVA_HOME is undefined was not being printed to the Chef output. When running chef solo, debugging output can be turned on by appending -l debug to the command, as in: chef-solo -c

Berkshelf cookbooks are not being copied to the Vagrant directory

允我心安 提交于 2019-12-05 01:09:55
问题 I am trying to provision a Vagrant machine using Chef-solo, Berkshelf, and the vagrant-berkshelf plugin. However, the provisioning fails with this error: Berkshelf::CookbookNotFound: Cookbook <cookbook name> not found in any of the default locations berks install successfully installs everything to ~/.berkshelf/cookbooks/ , but the cookbooks are never copied over to ~./berkshelf/default/vagrant/berkshelf-20131017-8441-pqghfq-default which is where Berkshelf reports it is updating, right

Why can't chef resolve my cookbooks?

百般思念 提交于 2019-12-04 23:03:16
Intro I am learning Chef to automate the server management at work. I downloaded chefdk 3.0 from here and now I am trying to build my first cookbook using chef. Important I am using this in a Windows environment for testing purpose, I do expect it to fail since Windows does not have iptables, but I do not expect it to fail saying that it can't find the cookbook. I've tried using Windows cookbook and it works. The problem I am able to create the cookbook and run it, but I am not able to reference dependencies from supermarket. I have tried two alternatives: Alternative 1 I used the following

chef rewind cookbook_file definition from a wrapper cookbook recipe

佐手、 提交于 2019-12-04 21:33:01
I am using an cookbook github.com opscode-cookbooks/openldap. I wrote an wrapper cookbook "lab_openldap" that includes "openldap::server" recipe. The server.rb recipe uses following clausule to upload the PEM file from cookbooks files/ssl/*.pem to server to the location node['openldap']['ssl_cert']. if node['openldap']['tls_enabled'] && node['openldap']['manage_ssl'] cookbook_file node['openldap']['ssl_cert'] do source "ssl/#{node['openldap']['server']}.pem" mode 00644 owner "root" group "root" end end The PEM is tried to be read from "openldap" cookbook file/ssl/#{node['openldap']['server']}

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

≡放荡痞女 提交于 2019-12-04 19:17:56
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_masterkey", secret) What logic do i need to add to pass on the data bag secret to a docker container? I've

How do I share code across Chef cookbooks in a chef-repo?

谁说胖子不能爱 提交于 2019-12-04 19:03:41
问题 I would like to share a small handful of methods across recipes in a chef repo. I know that on a cookbook level I can put code in modules in the libraries directory (see related question). What I'm looking for is something like that but available across all of the cookbooks in my Chef repo. I can think of a couple solutions: Create a gem, install the gem as part of the chef run. This seems like overkill. Put the file in some folder and add that folder to the $LOAD_PATH in the recipe file. I

Using a Chef recipe to append multiple lines to a config file

只愿长相守 提交于 2019-12-04 18:10:21
问题 I'm trying to create a Chef recipe to append multiple lines (20-30) to a specific config file. I'm aware the recommended pattern is to change entire config files rather than just appending to a file, but I dislike this approach for multiple reasons. So far the only solution I found was to use a cookbook_file and then use a bash resource to do: cat lines_to_append >> /path/configfile Obviously this wouldn't work properly, as it'd append the file over and over, each time you run chef-client. I

Checkout git repo with chef with ssh key

◇◆丶佛笑我妖孽 提交于 2019-12-04 17:39:06
Hello I am having issues getting chef to checkout my git repo using an ssh key from my data_bag. Below is my git resource: repo_key = search(:git, "id:git_key").first git_key_file = "#{Chef::Config['file_cache_path']}/git_key/id_rsa" directory "#{Chef::Config['file_cache_path']}/git_key" do action :create end file git_key_file do content repo_key['deploy_key'] mode "0755" action :create_if_missing end git "/usr/share/my_repo" do repository "git@github.com:my_name/some_repo.git" checkout_branch "#{node["my_app"][:test_branch]}" action :sync ssh_wrapper "ssh -i #{git_key_file}" end When I run:

Adding chef cookbooks from github

佐手、 提交于 2019-12-04 17:00:35
问题 I've downloaded a number of cookbooks from the opscode site using the command: knife cookbook site install git for example. However now I would like to download a cookbook from a repository on github into my current cookbooks directory. How should I go about doing this? should I just clone the repository into my cookbooks directory? Thank you! 回答1: You coould install the knife github plugin from https://github.com/websterclay/knife-github-cookbooks, after which you could simply use knife