How to install Samba Server and CIFS client on Linux with Chef

Configuring Samba server with Chef

Recently, I have automated the Samba server and CIFS client on centos with the help of Chef.

The Cookbook is, of course, available on super-market but in production, you are not allowed to copy someone else code.

If you are new or still in the learning phase, this blog will provide you the overview of the directory structure and how we are dealing with the various resources of Chef in production.

The first thing we will create is the Chef directories as below,

Now we will look one by one the configuration of files.

Cookbooks/samba/recipes/server.rb

The above code is self-explanatory, no matter if you know Chef DSL or not.

For any kind of help with Chef, resources visit the link https://docs.chef.io/

Let’s look into the client side configurations.

Cookbooks/samba/recipes/client.rb

Note***

{execute “changes_mount_dir_per” do — end } is not important you can skip.

Again the above code is pretty much easy to understand.

Cookbooks/samba/templates/smb.conf.erb

The above code is the configuration of samba which you will find after cheffing the server in “/etc/samba/” directory.

roles/samba_client.json

roles/samba_server.json

Roles, which can be assigned to multiple nodes which include the run_list with the recipe you want to run from particular cookbooks.

nodes/smb.json

nodes/smb_cifs.json

Nodes belong to particular server configurations which include Roles to run.

Ok, Now you can do the above stuff without Roles or Nodes but I have followed the standard approach which you can easily modify to multiple Cookbooks, Nodes, Roles.

Cooking the server with node

Login to the samba server and type the below command in a terminal you will see the client connected,

The same way login to your client server and verify the mount directory by creating files/folder.

That’s it for now, see you in the next useful blogs.

Askops
Askops
Developer: Nikhil raj
Price: Free

Leave a Reply