Questions at the top. Details and explanations and sources are below.
FIRST QUESTION: how do I actually fetch someone else’s LWRP? Do I git clone it into my chef_repo/cookbooks directory (if it’s on github, for example)? Or some other something?
SECOND QUESTION: what do I need to put in the …/recipe/default.rb and …/metadata.rb to be able to use a given LWRP in my …/recipes/default.rb. I’m a bit confused because the ‘include_recipe’ statement is for, well, recipes, not cookbooks.
Discussion:
============================
I’m experimenting with chef using chef-client -z mode on centos7. chef is v12-whatever is current in the chef-stable.repo.
I’ve written very simple recipes, such as creating and permissioning a /pub directory. Worked great.
[vagrant@cw chef_repo]$ pwd
/home/vagrant/chef_repo
[vagrant@cw chef_repo]$ sudo chef-client -z cookbooks/pub/recipes/default.rb
<snip>
[vagrant@cw chef_repo]$ ls -la /pub
total 4
drwxrwsr-x. 2 nobody pub 6 Apr 27 06:03 .
now, for the purposes of this discussion, let’s say I want to do acls. And in fact, there’s a lovely LWRP that looks like it’ll do just fine at
https://github.com/nightw/posix_acl
FIRST QUESTION: how do I fetch it? Do I git clone it into my chef_repo/cookbooks directory? Or some other something?
Assuming the answer to question 1 is ‘git clone’ into my cookbooks directory…
SECOND QUESTION: what do I need to put in the pub/recipe/default.rb and pub/metadata.rb to be able to use the posix_acl call in my pub/recipes/default.rb. I’m a bit confused because the ‘include_recipe’ statement is for, well, recipes, not cookbooks.
=============================
Here are the gory details. I understand what most of the words in the error messages (at the bottom) are saying, but I don’t know how to parse them out into a solution. As the comedian says…‘a little help here…?’
Thanks.
Gory details:
[vagrant@cw chef_repo]$ ls -la cookbooks/
total 16
drwxrwxr-x. 4 vagrant vagrant 48 Apr 27 06:24 .
drwxrwxr-x. 7 vagrant vagrant 4096 Apr 26 07:05 ..
drwxrwxr-x. 6 vagrant vagrant 4096 Apr 27 06:22 posix_acl
drwxrwxr-x. 6 vagrant vagrant 4096 Apr 26 07:07 pub
-rw-rw-r--. 1 vagrant vagrant 3147 Apr 26 07:05 README.md
[vagrant@cw chef_repo]$
=============================
This works fine:
[vagrant@cw ~] cd chef_repo/ [vagrant@cw chef_repo] cat cookbooks/pub/recipes/default.rb
Cookbook:: pub
Recipe:: default
Copyright:: 2017, The Authors, All Rights Reserved.
user ‘nobody’ do
comment 'the nopriv nobody user’
uid '99’
shell '/bin/nologin’
end
group ‘pub’ do
action :create
gid '470’
append true
end
directory ‘/pub’ do
action :create
owner 'nobody’
group 'pub’
mode '02775’
end
====================================
This doesn’t:
====================================
[vagrant@cw chef_repo]$ cat cookbooks/pub/metadata.rb
name 'pub'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'All Rights Reserved'
description 'Installs/Configures pub'
long_description 'Installs/Configures pub'
version '0.1.0'
chef_version '>= 12.1' if respond_to?(:chef_version)
# The `issues_url` points to the location where issues for this cookbook are
# tracked. A `View Issues` link will be displayed on this cookbook's page when
# uploaded to a Supermarket.
#
# issues_url 'https://github.com/<insert_org_here>/pub/issues'
# The `source_url` points to the development reposiory for this cookbook. A
# `View Source` link will be displayed on this cookbook's page when uploaded to
# a Supermarket.
#
# source_url 'https://github.com/<insert_org_here>/pub'
depends 'posix_acl'
=========================
[vagrant@cw chef_repo]$ cat cookbooks/pub/recipes/default.rb
#
# Cookbook:: pub
# Recipe:: default
#
# Copyright:: 2017, The Authors, All Rights Reserved.
include_recipe ‘posix_acl::default’
user ‘nobody’ do
comment 'the nopriv nobody user’
uid '99’
shell '/bin/nologin’
end
group ‘pub’ do
action :create
gid '470’
append true
end
directory ‘/pub’ do
action :create
owner 'nobody’
group 'pub’
mode '02775’
end
posix_acl “/pub” do
group 'pub’
read true
write true
execute true
recursive true
default true
end
==================================
[vagrant@cw chef_repo]$ sudo chef-client -z cookbooks/pub/recipes/default.rb
[2017-04-27T07:11:22+01:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /home/vagrant
One version per cookbook
[2017-04-27T07:11:22+01:00] INFO: Forking chef instance to converge…
Starting Chef Client, version 12.19.36
[2017-04-27T07:11:22+01:00] INFO: *** Chef 12.19.36 ***
[2017-04-27T07:11:22+01:00] INFO: Platform: x86_64-linux
[2017-04-27T07:11:22+01:00] INFO: Chef-client pid: 5198
[2017-04-27T07:11:24+01:00] INFO: Run List is []
[2017-04-27T07:11:24+01:00] INFO: Run List expands to []
[2017-04-27T07:11:24+01:00] INFO: Starting Chef Run for chef_admin
[2017-04-27T07:11:24+01:00] INFO: Running start handlers
[2017-04-27T07:11:24+01:00] INFO: Start handlers complete.
[2017-04-27T07:11:24+01:00] INFO: HTTP Request Returned 404 Not Found: Object not found:
resolving cookbooks for run list: []
[2017-04-27T07:11:24+01:00] INFO: Loading cookbooks []
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks…
[2017-04-27T07:11:24+01:00] WARN: MissingCookbookDependency:
Recipe posix_acl::default
is not in the run_list, and cookbook 'posix_acl’
is not a dependency of any cookbook in the run_list. To load this recipe,
first add a dependency on cookbook ‘posix_acl’ in the cookbook you’re
including it from in that cookbook’s metadata.
Running handlers:
[2017-04-27T07:11:24+01:00] ERROR: Running exception handlers
Running handlers complete
[2017-04-27T07:11:24+01:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2017-04-27T07:11:24+01:00] FATAL: Stacktrace dumped to /home/vagrant/.chef/local-mode-cache/cache/chef-stacktrace.out
[2017-04-27T07:11:24+01:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-04-27T07:11:24+01:00] ERROR: Cookbook posix_acl not found. If you’re loading posix_acl from another cookbook, make sure you configure the dependency in your metadata
[2017-04-27T07:11:24+01:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)