Continuation of the previous lab(3rd)

1. Executing Linux Commands in Chef

Chef allows you to execute Linux commands inside recipes using the execute resource. This is useful for tasks like creating directories, files, or running shell commands.

Steps to Execute Linux Commands:

  1. Login to Amazon Linux Machine:

    sudo su
    cd cookbooks
    ls
    
  2. Create a Recipe to Run Linux Commands:

    vi test-cookbook/recipes/test-recipe.rb
    
  3. Run the Recipe:

    chef-client -zr "recipe[test-cookbook::test-recipe]"
    
  4. Verify the Changes:

    ls /
    

2. Creating Users & Groups in Chef

Chef allows creating system users and groups using the user and group resources.

Creating a User:

  1. Edit the Recipe:

    vi test-cookbook/recipes/test-recipe.rb
    
  2. Run the Recipe:

    chef-client -zr "recipe[test-cookbook::test-recipe]"
    

Creating a Group & Adding a User:

  1. Edit the Recipe:

    vi test-cookbook/recipes/test-recipe.rb
    
  2. Run the Recipe:

    chef-client -zr "recipe[test-cookbook::test-recipe]"
    
  3. Verify the Group Creation:

    cat /etc/group