Template not creating file on Ubuntu 14

I have a simple motd rule that is failing on bootstrap because it says the file doesn’t exist. The stack trace says “create” is true. The rule works fine on ubuntu 12/13. Do you think this is a bug?

the code in question:

template “/etc/motd” do
source "motd.erb"
owner "root"
group "root"
mode "0644"
force_unlink true
end

On Wed, May 7, 2014 at 11:59 AM, Bannon, Steve steve.bannon@nist.gov wrote:

I have a simple motd rule that is failing on bootstrap because it says the file doesn’t exist. The stack trace says “create” is true. The rule works fine on ubuntu 12/13. Do you think this is a bug?

the code in question:

template "/etc/motd" do
source "motd.erb"
owner "root"
group "root"
mode "0644"
force_unlink true
end

Does /etc/motd exist as a link to /var/run/motd before-hand?

Bryan

It may be this bug.

https://tickets.opscode.com/browse/CHEF-5015

Bryan

In ubuntu12 it is a link and the force_unlink works. If I remove it before I bootstrap it fails. I’m trying a test without the force unlink

Steve

On May 12, 2014, at 1:44 PM, Bryan McLellan btm@loftninjas.org wrote:

On Wed, May 7, 2014 at 11:59 AM, Bannon, Steve steve.bannon@nist.gov wrote:

I have a simple motd rule that is failing on bootstrap because it says the file doesn’t exist. The stack trace says “create” is true. The rule works fine on ubuntu 12/13. Do you think this is a bug?

the code in question:

template "/etc/motd" do
source "motd.erb"
owner "root"
group "root"
mode "0644"
force_unlink true
end

Does /etc/motd exist as a link to /var/run/motd before-hand?

Bryan

On Wednesday, May 7, 2014 at 8:59 AM, Bannon, Steve wrote:

I have a simple motd rule that is failing on bootstrap because it says the file doesn’t exist. The stack trace says “create” is true. The rule works fine on ubuntu 12/13. Do you think this is a bug?

the code in question:

template "/etc/motd" do
source "motd.erb"
owner "root"
group "root"
mode "0644"
force_unlink true
end

Can we see the error message and stacktrace? This isn’t enough information to figure out what’s going on.

--
Daniel DeLeo

Actually it doesn't work on ubuntu 12/13 also

They have links in place, which chef removes and replaces based on the template. If I remove the file, it fails. Here's the stacktrace:

  • template[/etc/motd] action create
    ================================================================================
    Error executing action create on resource 'template[/etc/motd]'
    ================================================================================

Errno::ENOENT

No such file or directory - /etc/motd

Resource Declaration:

In /var/chef/cache/cookbooks/base/recipes/default.rb

36: template "/etc/motd" do
37: source "motd.erb"
38: owner "root"
39: group "root"
40: mode "0644"
41: force_unlink true
42: end
43:

Compiled Resource:

Declared in /var/chef/cache/cookbooks/base/recipes/default.rb:36:in `from_file'

template("/etc/motd") do
provider Chef::Provider::Template
action "create"
retries 0
retry_delay 2
path "/etc/motd"
backup 5
atomic_update true
force_unlink true
source "motd.erb"
cookbook_name "base"
recipe_name "default"
owner "root"
group "root"
mode "0644"
end

Running handlers:
[2014-05-09T13:41:18-04:00] ERROR: Running exception handlers
[2014-05-09T13:41:18-04:00] ERROR: Report handler MailHandler raised #<Errno::ECONNREFUSED: Connection refused - connect(2)>
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/1.9.1/net/smtp.rb:540:in initialize' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/1.9.1/net/smtp.rb:540:in open'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/1.9.1/net/smtp.rb:540:in tcp_socket' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/1.9.1/net/smtp.rb:549:in block in do_start'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/1.9.1/timeout.rb:69:in timeout' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/1.9.1/timeout.rb:100:in timeout'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/1.9.1/net/smtp.rb:549:in do_start' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/1.9.1/net/smtp.rb:519:in start'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in deliver!' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mail-2.5.4/lib/mail/message.rb:248:in deliver!'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pony-1.8/lib/pony.rb:143:in deliver' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pony-1.8/lib/pony.rb:137:in mail'
[2014-05-09T13:41:18-04:00] ERROR: /etc/chef/handlers/mail/mail.rb:58:in report' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/handler.rb:226:in run_report_unsafe'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/handler.rb:214:in run_report_safely' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/handler.rb:118:in block in run_exception_handlers'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/handler.rb:117:in each' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/handler.rb:117:in run_exception_handlers'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/handler.rb:127:in block in <class:Handler>' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:122:in call'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:122:in block in run_failed' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:121:in each'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:121:in run_failed' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:431:in rescue in do_run'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:441:in do_run' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:200:in block in run'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:194:in fork' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/client.rb:194:in run'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/application.rb:215:in run_chef_client' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/application/client.rb:314:in block in run_application'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/application/client.rb:306:in loop' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/application/client.rb:306:in run_application'
[2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/lib/chef/application.rb:66:in run' [2014-05-09T13:41:18-04:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.4/bin/chef-client:26:in <top (required)>'
[2014-05-09T13:41:18-04:00] ERROR: /usr/bin/chef-client:23:in load' [2014-05-09T13:41:18-04:00] ERROR: /usr/bin/chef-client:23:in '

  • MailHandler
    Running handlers complete

[2014-05-09T13:41:18-04:00] ERROR: Exception handlers complete
[2014-05-09T13:41:18-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 5 resources updated in 1.406818958 seconds
[2014-05-09T13:41:18-04:00] ERROR: template[/etc/motd] (base::default line 36) had an error: Errno::ENOENT: No such file or directory - /etc/motd
[2014-05-09T13:41:18-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
chef@chefclient:~$

Another thing I didn't mention is that if I touch the file before I run chef-client it works just fine.

Thanks
Steve


From: Daniel DeLeo ddeleo@kallistec.com on behalf of Daniel DeLeo dan@kallistec.com
Sent: Friday, May 09, 2014 11:33 AM
To: chef@lists.opscode.com
Subject: [chef] Re: template not creating file on Ubuntu 14

On Wednesday, May 7, 2014 at 8:59 AM, Bannon, Steve wrote:

I have a simple motd rule that is failing on bootstrap because it says the file doesn’t exist. The stack trace says “create” is true. The rule works fine on ubuntu 12/13. Do you think this is a bug?

the code in question:

template "/etc/motd" do
source "motd.erb"
owner "root"
group "root"
mode "0644"
force_unlink true
end

Can we see the error message and stacktrace? This isn’t enough information to figure out what’s going on.

--
Daniel DeLeo