Skip to main content

Posts

Showing posts with the label cookbook

Remove a user and its home directory with chef-cookbook

This will be another example for  #Opscode    #Chef . We will just extend the cookbook in the previous post to add a new recipe; we will add some extra lines to attributes file and write new simple recipe. Let's start with attributes file. To remove a user, required attribute is its name. Let's provide it: default['ruser']['name'] = "username" We will add an attribute which will specify whether to remove or keep home directory of removed user. Perhaps, it will be kept in the archive. Therefore, as default I set it false. default['ruser']['removehome'] = false

Simple Chef Cookbook Example - Create a user

To begin writing a cookbook, the first thing you need to do is to create a cookbook with boilerplate content via running knife command: knife cookbook create newuser . For this simple cookbook, we will edit three basic contents; attributes, metadata, recipes. First let's go over metadata. Content of metadata is some hints about cookbooks for the server; dependencies, licence, version and other general information. These helps to do correct deployment to clients.