Sunday, July 30, 2017

How to create users using the chef cookbook?

Manual process:
useradd Sai  (To create the new user)
id sai (This is to verify,whether the user has created or not).
(uid=1002(sai) gid=1002(sai) groups=1002(sai))


Chef process using Recipe in the users cookbook:

user 'kevin' do
  comment 'default user'
  home '/home/kevin'
  shell '/bin/bash'
  password 'kevin'
end

This should be mentioned in the Chef - Recipe (default.rb).


How to write a test condition for the users cookbook?

describe user('Sai') do
it { should exist }
its('uid') { should eq 1001 }
its('shell') { should eq '/bin/bash' }
end

where we need to place this piece of code?

users (cookbook) >   test (directory) >  smoke  (directory) >   default  (directory) > default_test.rb

What is the necessity of test condition (Inspec test)?(the test condition will checkin for every 30mins on to the node,to know the status of the node and make sure whether it is satisfying the test condition or not).

whenever anything is not working properly/it is overrided / it is been removed/deleted,the test condition will fail,whenever there is a failure of test condition automatically the Chef-recipe is again applied on to the nodes and fulfill the requirement of the users cookbook.

No comments:

Post a Comment