1
votes

i try to create users on remote system by chef/knife, but something goes wrong... here is my steps:

  1. installing "user" cookbook

knife cookbook site install user

  1. creating data bag for it

knife data bag create users

  1. creating a json file with options

cat data_bags/users/fatal.json
{
"id": "fatal",
"uid": "1002",
"home": "/home/fatal",
"groups": "sudo",
"shell": "/bin/bash",
"password": "$6$wkWXnXUk$xjaISNyG3cDGU2XYBAf."
}

  1. exporting it in my data bag

knife data bag from file users data_bags/users/fatal.json

  1. adding recipe "user" to my remote node

knife node chef-test-client show
Node Name: chef-test-client
Environment: _default
FQDN: chef-test-client
IP: 192.168.16.777
Run List: recipe[group], recipe[user]
Roles:
Recipes: group, user
Platform: debian 7.1
Tags:

  1. uploading it on knife server

knife cookbook upload user

  1. synchronizing on my remote node

chef-client
Starting Chef Client, version 11.8.0
resolving cookbooks for run list: ["group::data_bag", "user::data_bag"]
Synchronizing Cookbooks:
- user
- group
Compiling Cookbooks...
Converging 0 resources
Chef Client finished, 0 resources updated

so nothing happens, user is not created; what am i doing wrong ?, guys please help me to deal with it

UPDATE:

in USAGE section on http://fnichol.github.io/chef-user/

To use recipe[user::data_bag], include it in your run_list and have a data bag called >"users"

so i changed my Run List settings to:

knife node show chef-test-client  
Node Name:   chef-test-client  
Environment: _default  
FQDN:        chef-test-client   
IP:          192.168.16.777  
Run List:    recipe[user::data_bag], recipe[group::data_bag]  
Roles:         
Recipes:     user::data_bag, group::data_bag  
Platform:    debian 7.1  

and my data bag:

knife data bag show users fatal  
groups:   sudo  
home:     /home/fatal  
id:       fatal  
password:  >$6$wkWXnXUk$xjaISNyG3cDGU2X  
shell:    /bin/bash  
uid:      1002  

and nothing happens again :(

2

2 Answers

3
votes

You are using this cookbook: http://fnichol.github.io/chef-user/

According to that description, I think that you have to explicitly add the fatal user to node[:users].

1
votes

StephenKing is right. you must add: default["users"] = ["users", "to", "load"] to your attributes. I think the idea is that the data bag has all of the domains users, but each node decides what users to load from the data bag by name.