# Running a hostfile cookbook on OpsWorks

**URL:** <https://discourse.chef.io/t/running-a-hostfile-cookbook-on-opsworks/7783>\
**Category:** Chef Infra (archive)\
**Created:** [February 10, 2016, 11:04am UTC](https://discourse.chef.io/t/running-a-hostfile-cookbook-on-opsworks/7783 "2016-02-10T11:04:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Hawkins](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@Simon\_Hawkins](https://discourse.chef.io/u/Simon_Hawkins)\
**Post date:** [February 10, 2016, 11:04am UTC](https://discourse.chef.io/t/running-a-hostfile-cookbook-on-opsworks/7783/1 "2016-02-10T11:04:12Z")

</div>

Hi,

I’m trying to run a cookbook called hostsfile on Opsworks and get the following error in the log:

17: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
18: # See the License for the specific language governing permissions and  
19: # limitations under the License.  
20: #  
21:  
22: default[‘hostsfile’][‘path’] = nil  
23:  
24\>\> hostsfile\_entry ‘x.x.x.x’ do  
25: hostname 'blah.blah’  
26: aliases 'blah’  
27: action :create\_if\_missing  
28: end  
29:  
30: hostsfile\_entry ‘x.x.x.x’ do  
31: hostname 'blah2.blah’  
32: aliases 'blah2’  
33: action :create\_if\_missing

[2016-02-10T10:27:31+00:00] ERROR: Running exception handlers  
[2016-02-10T10:27:31+00:00] ERROR: Exception handlers complete  
[2016-02-10T10:27:31+00:00] FATAL: Stacktrace dumped to /var/chef/runs/02e3fa28-25c3-42ff-a90e-d6690118f492/local-mode-cache/cache/chef-stacktrace.out  
[2016-02-10T10:27:31+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report  
[2016-02-10T10:27:31+00:00] ERROR: Undefined node attribute or method `hostsfile_entry' on`node’  
[2016-02-10T10:27:32+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

The cookbook i am using is stored like this:

hostsfile  
├── attributes  
│ └── default.rb  
├── [CHANGELOG.md](http://CHANGELOG.md)  
├── libraries  
│ ├── entry.rb  
│ ├── manipulator.rb  
│ └── matchers.rb  
├── metadata.json  
├── metadata.rb  
├── providers  
│ └── entry.rb  
├── [README.md](http://README.md)  
├── recipes  
│ └── default.rb  
└── resources  
└── entry.rb

Any idea why it can’t find the resource?

Cheers,  
Simon.

---

<div class="post-metadata">

**Author:** ![Angus\_Buchanan](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@Angus\_Buchanan](https://discourse.chef.io/u/Angus_Buchanan)\
**Post date:** [February 10, 2016, 12:37pm UTC](https://discourse.chef.io/t/running-a-hostfile-cookbook-on-opsworks/7783/2 "2016-02-10T12:37:04Z")

</div>

Hello,

---

<div class="post-metadata">

**Author:** ![yoshiwaan](https://avatars.discourse-cdn.com/v4/letter/y/ba9def/32.png) [@yoshiwaan](https://discourse.chef.io/u/yoshiwaan)\
**Post date:** [February 10, 2016, 4:50pm UTC](https://discourse.chef.io/t/running-a-hostfile-cookbook-on-opsworks/7783/3 "2016-02-10T16:50:47Z")

</div>

So your opswork stack has been set up to:

1. have the ‘Use custom Chef cookbooks’ option on
2. You’ve specified a cookbook bundle via github or S3 or something which  
contains your monorepo, including the hostsfile cookbook (or it’s in a  
Berksfile for the Chef 11.10 stack)

---

<div class="post-metadata">

**Author:** ![Simon\_Hawkins](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@Simon\_Hawkins](https://discourse.chef.io/u/Simon_Hawkins)\
**Post date:** [February 11, 2016, 8:41am UTC](https://discourse.chef.io/t/running-a-hostfile-cookbook-on-opsworks/7783/4 "2016-02-11T08:41:40Z")

</div>

Hi,

I am using our github server to store the cookbooks. All other cookbooks work fine apart from this one. I am also using a Chef 12 stack in opsWorks, which this cookbook may not support?

Cheers,  
Simon.

---

<div class="post-metadata">

**Author:** ![yoshiwaan](https://avatars.discourse-cdn.com/v4/letter/y/ba9def/32.png) [@yoshiwaan](https://discourse.chef.io/u/yoshiwaan)\
**Post date:** [February 11, 2016, 6:00pm UTC](https://discourse.chef.io/t/running-a-hostfile-cookbook-on-opsworks/7783/5 "2016-02-11T18:00:54Z")

</div>

Nah, the hostfile cookbook definitely works in Chef 12.

You might need to SSH onto the box which has the failing Chef run and make  
sure that it’s actually downloading the hostsfile cookbook into the  
directory that the Chef run uses for cookbooks, I’m not sure how Opsworks  
works out what cookbook to send where or if it just sends them all  
everywhere.

Is the hostsfile cookbook somewhere in your dependency tree (i.e. the  
cookbook that tries to use the hostsfile\_entry resource on a lifecycle  
event has depends ‘hostsfile’ in its metadata.rb)?

Does your opsworks stack point to the right branch in github?
