| popularity | question | answers | views | user | |
|---|---|---|---|---|---|
| 0 |
Overriding variables twice
I’m having an issue where I run the following opscode cookbooks but I’m overriding the java “install_flavor” to use “oracle”.
The initial java recipe installs oracle version of java however, tomcat also includes java which for some reason runs and installs and openjdk regardless of the following override.
Am I doing something wrong? Thanks for your help, Joe |
0 | 34 | ||
| 0 |
First run attributes on chef-client 11 for windows
Hi, I have some troubles importing attributes at first run with chef-clietn 11 for windows. I have a json file “c:/chef/first-boot.json” with similar content {“company”:{“company_name”:“My Company”},“run_list”:[“role[server_role]”]} I start the client with this line chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json I have a role, which is applied correctly and all recipes for that role are started to compile and run. However, if I want to use the “company” attribute at the first run, the attribute is missing (for example node[:company][:company_name] gives me “NoMethodError”, because node[:company] do not exist). If I do not use this attribute (i.e. all recipes pass trough the first run), the attribute node[:company] appears in the chef server and I can use it on the next run. This method for first run attributes works well on linux chef-client. There I’m able to use the node[:company] attribute on the first run without any problems. Am I doing something wrong or there is some limitation for chef-client for windows? Here is my log from the console chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json -E dev INFO: Chef 11.4.0 INFO: Client key c:/chef/client.pem is not present – registering INFO: Setting the run_list to [“role[server_role]”] from JSON INFO: Run List is [role[server_role]] INFO: Run List expands to [testbook::compnay_set] INFO: Starting Chef Run for node01 INFO: Running start handlers INFO: Start handlers complete. INFO: Loading cookbooks [testbook] Synchronizing Cookbooks: – sag_base – testbook Compiling Cookbooks… ================================================================================ Recipe Compile Error in c:/chef/cache/cookbooks/testbook/recipes/compnay_set.rb ================================================================================ NoMethodError undefined method `[]‘ for nil:NilClass Cookbook Trace: c:/chef/cache/cookbooks/testbook/recipes/install_dbc.rb:8:in `from_file' Relevant File Content: c:/chef/cache/cookbooks/testbook/recipes/install_dbc.rb: … 7: 8>> name = node[:company][:company_name] 9: … ERROR: Running exception handlers FATAL: Saving node information to c:/chef/cache/failed-run-data.json ERROR: Exception handlers complete Chef Client failed. 0 resources updated FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out FATAL: NoMethodError: undefined method `[]‘ for nil:NilClass |
0 | 121 | ||
| 0 |
Cannot Find Node Attribute
I am trying to install Munin through hosted Chef on a Vagrant VM. When installing the Munin Client, it performs a search for the Munin Servers.
However, this search is failing, with a 400 “Bad Request”. I did a quick check, and node[‘munin’][‘server_role’] is nil. But how can that be? It defines what it is in the Cookbooks attribute file. It sets it to “Monitoring”. I wanted to change that, so in the my Role I have:
I define node[‘munin’][‘server_role’] in that file. In fact, I went as far as to print out the entire node object:
And it shows:
I see it! I see my server_role has been defined! It’s right here! So why is it nil when I access it? What is happening? Chef Workstation Version: 10.24.0 Chef-Client Version: 10.24.0 Ruby Version: 1.9.3 |
0 | 68 | ||
| 2 |
Overriding attributes referenced by other attributes
I am having trouble understanding the proper way to define my recipe’s attributes and allow for certain ones to be overridden in roles. The classic example is where you have one attribute for the version of an external library and then another attribute that constructs a URL which references the first version attribute. Then, if the version number is overridden, the URL gets updated as well. Example: attributes/default.rb
recipes/default.rb
roles/noodle.rb
chef-client run output
Using ‘override_attributes’ instead of ‘default_attributes’ doesn’t make a difference:
chef-client run output
I have discovered that if I literally set one of those attributes on the node, it gets picked up. Set node attribute with ‘knife node edit NODE’:
Then a chef-client run shows:
Isn’t this what roles are for? I need to be able to manage attributes like this en masse and in source control (role files). There are several official cookbooks that are designed the same way such as java, couchdb, and munin so it seems like it should be supported somehow. |
1 | 1.3k | ||
| 0 |
Add environment attribute via Web Gui
Hello, I’m new to Chef, and I’m having trouble to add an envirionment attribute via Web Gui (Chef Server 0.10.8). I’m trying to add an attribute for the “resolve” cookbook, it’s an array of name servers. The JSON format should be: “resolver”: { “nameservers”: [ “8.8.8.8”,“8.8.4.4”], “search”: domain } How can I add these attributes in an Environment via Web Gui? I’ve tried some values, but it’s not working, and I can’t find the correct syntax, I’m receiving errors like this: “SyntaxError: Unexpected token a” Thank you. Alexandre |
1 | 617 | ||
| 1 |
How to add attributes per node?
I wan’t to setup virtual interfaces, but only on a host, so i wan’t to put somewhere something like this:
As reading the documentation, there is no info (or i can’t find that), to do that. The first attempt, was to write
with the config, but opposite than the feel of documentation made on me… it doesn’t work. Then i tried “knief node edit”, but i don’t want to set up each node this way, and want to save the node conf in the git chef-repo. The other way was to use data_bags, but the problem there is… why i wan’t attributes, if i have to load it all from data_bags. So I can’t find the way to set specific attribute to a single node. |
1 | 889 |
