[chef] Re: Re: Re: Re: Overriding default attributes


Chronological Thread 
  • From: Leonard Messier < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Overriding default attributes
  • Date: Thu, 6 Feb 2014 14:05:25 +0100

Hi,

First, editing the metadata file solved the issue indeed !

However, I have a problem in the logic of the process I'm trying to put in place.

I need to update the /etc/default/grub file 
But My user doesn't have sudo privileges
I use chef-solo with sudo to achieve that
My rspec tests start to fail because I don't launch rspec with sudo, why should I
I try to allow my user to act as sudo without using a password
I try to use the sudo cookbook that configures the sudoers file
I need to create a sysadmin group and let my user belong to it 
I try to use the users cookbook that edits the system group file to add a sysadmin group
Chef fails because my user doesn't have sudo privileges to edit the group file

It all fails like it should under such circumstances, but I'm wondering how you avoid such problems.
Do you launch the client with sudo once to allow the necessary operation to take place ? 
Do you do some operations manually, which kinda defeats the point of a provisioner ?


Thanks in advance


2014-02-05 18:25 GMT+01:00 Leonard Messier < " target="_blank"> >:
Thanks Daniel,

I had misunderstood the term « resource ». I thought it couldn't find the needed data bag. 
I was not aware of the need to specify dependencies in the metadata file when including a recipe in another. 
I think I should run foodcritic on my cookbooks to avoid such problems in the future.




2014-02-05 Daniel DeLeo < " target="_blank"> >:


On Wednesday, February 5, 2014 at 5:08 AM, Leonard Messier wrote:


Thanks Tom,

Changing it the way you did removed this error. However, another one appeared.

When trying to create the sudoers.d directory, chef complained about insufficient permissions. Reading further in the sudo's cookbook readme, I found a mention of the « sysadmin » group not beeing created by the sudo cookbook itself. 
I thought that I would install the users community cookbook, that essentially creates the sysadmin group when the sysadmins recipe is included. I created a users in data_bags/users, belonging to a sysadmin group. I get the following error :

Starting Chef Client, version 11.4.4
Compiling Cookbooks...

================================================================================
Recipe Compile Error in /home/virtualeo/.oh-my-chef/cookbooks/system/recipes/default.rb
================================================================================


NameError
---------
Cannot find a resource for users_manage on ubuntu version 13.04


Cookbook Trace:
---------------
/home/virtualeo/.oh-my-chef/vendor/cookbooks/users/recipes/sysadmins.rb:23:in `from_file'
/home/virtualeo/.oh-my-chef/cookbooks/system/recipes/default.rb:1:in `from_file'


Relevant File Content:
----------------------
/home/virtualeo/.oh-my-chef/vendor/cookbooks/users/recipes/sysadmins.rb:

16: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: # See the License for the specific language governing permissions and
18: # limitations under the License.
19: #
20:
21: # Searches data bag "users" for groups attribute "sysadmin".
22: # Places returned users in Unix group "sysadmin" with GID 2300.
23>> users_manage "sysadmin" do
24: group_id 2300
25: action [ :remove, :create ]
26: end
27:


[2014-02-05T13:54:52+01:00] ERROR: Running exception handlers
[2014-02-05T13:54:52+01:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2014-02-05T13:54:53+01:00] FATAL: Stacktrace dumped to /home/virtualeo/.chef/state/cache/chef-stacktrace.out
[2014-02-05T13:54:53+01:00] FATAL: NameError: Cannot find a resource for users_manage on ubuntu version 13.04

This means more or less what it says. There is no resource named `users_manage` defined. If you expect this to be provided by a LWRP, and you don’t have a typo or something, then the cookbook isn’t being loaded properly. On chef-solo, the most common cause of this is that you are using a cookbook that is not in your run_list and also not in the dependencies of any cookbooks in your run_list. Chef-solo will allow you to run recipes from such cookbooks, but the earlier stage of the chef run uses the run_list and dependency information to determine the correct order to load LWRPs, attributes files, and other non-recipe files. So a cookbook that isn’t in the run_list or reachable by dependencies won’t have its non-recipe files loaded, which will cause errors like this.

See also:


HTH,

-- 
Daniel DeLeo




--
Léonard Messier
Développeur web PHP/_javascript_/MySQL
http://www.leonardmessier.com



--
Léonard Messier
Développeur web PHP/_javascript_/MySQL
http://www.leonardmessier.com



Archive powered by MHonArc 2.6.16.

§