How do i access node['etc']['passwd']?

297 Views Asked by At

I'm trying to use the ohai resource to make node['etc']['passwd'] available. My recipe looks like this:

ohai 'reload etc plugin' do
  plugin 'etc'
  action :reload
end

log "Was etc plugin reloaded? #{node.key?('etc')}"

According to this answer this should work. But:

  * log[Was etc plugin reloaded? false] action write

What am I doing wrong?

This is with

Chef Infra Client: 17.0.242
Ohai: 17.0.42
1

There are 1 best solutions below

2
On BEST ANSWER

the following is noted on Reload Ohai after a new user is created in chef examples

ohai 'reload_passwd' do
  plugin 'etc'
end

and as you probably know, ohai does not load by the default](chef release notes) the Passwd plugin.

combining both with the ohai resource, and since the first snippet did not work for you, maybe the following will do the trick

ohai 'reload_passwd' do
  plugin 'passwd'
end

UPDATE: it seems that the version you specified had many issues. i suggest you will update chef version.