0
votes

I am learning Chef and berkshelf.com at the same time. Berkshelf is making it much easier to learn Chef, and I use a vagrant VM to test out my cookbooks.

I am able to provision my Vagrant VM just fine, but the users (from knife data bag) and the sysadmin group is not getting created during a provision.

Here are the steps I've taken:

/opt/chefdk/bin/knife data bag create users
/opt/chefdk/bin/knife data bag create users foo

Here is the json:

{
  "id": "foo",
  "groups": [ "sysadmin" ]
}

Here is my default.rb recipe:

include_recipe "users::sysadmins"

Here is my Vagrantfile (I removed my private info and replaced with xxx):

VAGRANTFILE_API_VERSION = '2'

Vagrant.require_version '>= 1.5.0'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.hostname = 'chef-user-management-berkshelf'

  if Vagrant.has_plugin? 'vagrant-omnibus'
    config.omnibus.chef_version = 'latest'
  end

  config.vm.box = 'chef/centos-6.5'

  config.vm.network :private_network, type: 'dhcp'

  config.berkshelf.enabled = true

  config.vm.provision :chef_client do |chef|
    chef.validation_client_name = "xxxx"
    chef.chef_server_url = "xxx"
    chef.validation_key_path = "/my/path/to/the.pem"
    chef.json = {
      mysql: {
        server_root_password: 'rootpass',
        server_debian_password: 'debpass',
        server_repl_password: 'replpass'
      }
    }

    chef.run_list = [
      'recipe[user-management::default]'
    ]
  end
end

And then running:

vagrant provision

I've also verified the data bag on my chef server and run vagrant as :chef_client. The runs are succeeding Any ideas what I might be missing?

Note: I've made a wrapper cookbook of the Chef users cookbook to add my own user logic/configuration.

1
Please include your wrapper code so I can see what it does.coderanger
Basically its a vanilla project from running berks cookbook user-management. I will add more logic, but for now I only have a default recipe which has one line: include_recipe "users::sysadmins". Sorry, this is my first cookbook with Data Bags. Interestingly, if I change the run list to run the sysadmins recipe directly, it seems to work now. Don't know what I'm missing, but I want this to wrap similar to how github.com/RiotGames/java works.Paul Redmond
Maybe you didn't upload your wrapper cookbook correctly?coderanger
@coderanger thanks for your help. I was using chef solo when I first started, and once I bumped my cookbook version it started working +1.Paul Redmond

1 Answers

1
votes

Solved in comments, just needed to re-upload the cookbook.