Out-of-the-box chef-client cookbook has no interval dial

hiya,

at this point in my chef infancy i’m under the impression that i should
be able to use community cookbooks as is for basic functionality, and
shouldn’t generally need to modify them. if i need to modify attributes,
i do that in an attribute override.

i’m trying to do that for the chef-client interval. it defaults to
1800 in the cookbook’s default attributes. i have an override in my
base role:

[chefrepo]$ knife role show base -a override_attributes
override_attributes:
chef_client:
init_style: init
interval: 21600
server_url: https://chef.dev.blueangelsinmypance.com
validation_client_name: chef-validator

(yes, i’ll go with 1800 interval at a later time in my deployment.)

but this isn’t working - an interval line in my client’s config doesn’t
appear. i’m pretty sure the reason is because there is no interval
line in the template:

cookbooks/chef-client/templates/default/client.rb.erb

should i modify that template or is there a better "best practices"
way to handle this?

and so, i go ahead and add a line to that template, run the client,
and get an error…

my change:

— client.rb.erb 2011-10-07 00:53:10.000000000 +0000
+++ client.rb.erb.new 2011-10-07 00:53:03.000000000 +0000
@@ -13,6 +13,7 @@

Using default node name

<% end -%>

+interval "<%= node[“chef_client”][“interval”] %>"
file_backup_path "<%= node[“chef_client”][“backup_path”] %>"
file_cache_path “<%= node[“chef_client”][“cache_path”] %>”

the error on the client:

[Fri, 07 Oct 2011 00:41:54 +0000] INFO: template[/etc/chef/client.rb] sending create action to ruby_block[reload_client_config] (delayed)
[Fri, 07 Oct 2011 00:41:54 +0000] INFO: Processing ruby_block[reload_client_config] action create (chef-client::config line 48)
[Fri, 07 Oct 2011 00:41:54 +0000] INFO: ruby_block[reload_client_config] called
[Fri, 07 Oct 2011 00:41:54 +0000] INFO: template[/etc/sysconfig/chef-client] sending restart action to service[chef-client] (delayed)
[Fri, 07 Oct 2011 00:41:54 +0000] INFO: Processing service[chef-client] action restart (chef-client::service line 73)
[Fri, 07 Oct 2011 00:42:00 +0000] INFO: service[chef-client] restarted
[Fri, 07 Oct 2011 00:42:00 +0000] INFO: Chef Run complete in 63.332668 seconds
[Fri, 07 Oct 2011 00:42:00 +0000] INFO: Running report handlers
[Fri, 07 Oct 2011 00:42:00 +0000] INFO: Report handlers complete
[Fri, 07 Oct 2011 00:42:00 +0000] ERROR: TypeError: can’t convert String into time interval
[Fri, 07 Oct 2011 00:42:00 +0000] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
[Fri, 07 Oct 2011 00:42:00 +0000] ERROR: Sleeping for 21600 seconds before trying again
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/application/client.rb:282:in select': can't convert String into time interval (TypeError) from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:282:inclient_sleep’
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/application/client.rb:263:in run_application' from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:inloop’
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/application/client.rb:229:in run_application' from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application.rb:67:inrun’
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-client:26
from /usr/bin/chef-client:19:in `load’
from /usr/bin/chef-client:19

halp? thanks!

kallen

Yo,

On 7 October 2011 13:55, kallen@groknaut.net wrote:

hiya,

at this point in my chef infancy i'm under the impression that i should
be able to use community cookbooks as is for basic functionality, and
shouldn't generally need to modify them. if i need to modify attributes,
i do that in an attribute override.

i'm trying to do that for the chef-client interval. it defaults to
1800 in the cookbook's default attributes. i have an override in my
base role:

[chefrepo]$ knife role show base -a override_attributes
override_attributes:
chef_client:
init_style: init
interval: 21600
server_url: https://chef.dev.blueangelsinmypance.com
validation_client_name: chef-validator

(yes, i'll go with 1800 interval at a later time in my deployment.)

but this isn't working - an interval line in my client's config doesn't
appear. i'm pretty sure the reason is because there is no interval
line in the template:

cookbooks/chef-client/templates/default/client.rb.erb

Sounds like a bug in the cookbook.

should i modify that template or is there a better "best practices"
way to handle this?

You could modify the template locally, open a ticket on the COOK
project, and/or supply the fix!

and so, i go ahead and add a line to that template, run the client,
and get an error..

my change:

--- client.rb.erb 2011-10-07 00:53:10.000000000 +0000
+++ client.rb.erb.new 2011-10-07 00:53:03.000000000 +0000
@@ -13,6 +13,7 @@

Using default node name

<% end -%>

+interval "<%= node["chef_client"]["interval"] %>"

Unfortunately, interval takes an integer - not a string. use:

interval <%= node["chef_client"]["interval"].to_i %>

Regards,

–AJ

file_backup_path "<%= node["chef_client"]["backup_path"] %>"
file_cache_path "<%= node["chef_client"]["cache_path"] %>"

the error on the client:

[Fri, 07 Oct 2011 00:41:54 +0000] INFO: template[/etc/chef/client.rb] sending create action to ruby_block[reload_client_config] (delayed)
[Fri, 07 Oct 2011 00:41:54 +0000] INFO: Processing ruby_block[reload_client_config] action create (chef-client::config line 48)
[Fri, 07 Oct 2011 00:41:54 +0000] INFO: ruby_block[reload_client_config] called
[Fri, 07 Oct 2011 00:41:54 +0000] INFO: template[/etc/sysconfig/chef-client] sending restart action to service[chef-client] (delayed)
[Fri, 07 Oct 2011 00:41:54 +0000] INFO: Processing service[chef-client] action restart (chef-client::service line 73)
[Fri, 07 Oct 2011 00:42:00 +0000] INFO: service[chef-client] restarted
[Fri, 07 Oct 2011 00:42:00 +0000] INFO: Chef Run complete in 63.332668 seconds
[Fri, 07 Oct 2011 00:42:00 +0000] INFO: Running report handlers
[Fri, 07 Oct 2011 00:42:00 +0000] INFO: Report handlers complete
[Fri, 07 Oct 2011 00:42:00 +0000] ERROR: TypeError: can't convert String into time interval
[Fri, 07 Oct 2011 00:42:00 +0000] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
[Fri, 07 Oct 2011 00:42:00 +0000] ERROR: Sleeping for 21600 seconds before trying again
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:282:in select': can't convert String into time interval (TypeError) from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:282:in client_sleep'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:263:in run_application' from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in loop'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in run_application' from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application.rb:67:in run'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-client:26
from /usr/bin/chef-client:19:in `load'
from /usr/bin/chef-client:19

halp? thanks!

kallen

On Fri, 07 Oct 2011, AJ Christensen wrote:

Yo,

cookbooks/chef-client/templates/default/client.rb.erb

Sounds like a bug in the cookbook.

should i modify that template or is there a better "best practices"
way to handle this?

You could modify the template locally, open a ticket on the COOK
project, and/or supply the fix!

will do.

Unfortunately, interval takes an integer - not a string. use:

interval <%= node["chef_client"]["interval"].to_i %>

i just tried that.. still getting error. i definately appreciate the
help here via mailing list, but let me know if i should just head over
to opscode jira..

the top 3 lines of that client.rb.erb are now:
log_level :info
log_location STDOUT
interval "<%= node["chef_client"]["interval"].to_i %>"

uploaded the cookbook.

still getting an error.

[Fri, 07 Oct 2011 01:12:59 +0000] ERROR: TypeError: can't convert String into time interval
[Fri, 07 Oct 2011 01:12:59 +0000] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
[Fri, 07 Oct 2011 01:12:59 +0000] ERROR: Sleeping for 21600 seconds before trying again
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:282:in select': can't convert String into time interval (TypeError) from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:282:in client_sleep'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:263:in run_application' from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in loop'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in run_application' from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application.rb:67:in run'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-client:26
from /usr/bin/chef-client:19:in `load'
from /usr/bin/chef-client:19

10/07 01:12[root@test-dev ~]# head -3 /etc/chef/client.rb
log_level :info
log_location STDOUT
interval "21600"

thoughts?

for shizzles i've tried both

  "interval": "21600",

and

  "interval": 21600,

in my override, like:
"override_attributes": {
"chef_client": {
"init_style": "init",
"interval": "21600",
"server_url": "https://chef.dev.sushimysavior.com",
"validation_client_name": "chef-validator"
}
}

Yo,

On 7 October 2011 14:22, kallen@groknaut.net wrote:

On Fri, 07 Oct 2011, AJ Christensen wrote:

Yo,

cookbooks/chef-client/templates/default/client.rb.erb

Sounds like a bug in the cookbook.

should i modify that template or is there a better "best practices"
way to handle this?

You could modify the template locally, open a ticket on the COOK
project, and/or supply the fix!

will do.

Unfortunately, interval takes an integer - not a string. use:

interval <%= node["chef_client"]["interval"].to_i %>

i just tried that.. still getting error. i definately appreciate the
help here via mailing list, but let me know if i should just head over
to opscode jira..

the top 3 lines of that client.rb.erb are now:
log_level :info
log_location STDOUT
interval "<%= node["chef_client"]["interval"].to_i %>"

uploaded the cookbook.

still getting an error.

[Fri, 07 Oct 2011 01:12:59 +0000] ERROR: TypeError: can't convert String into time interval
[Fri, 07 Oct 2011 01:12:59 +0000] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
[Fri, 07 Oct 2011 01:12:59 +0000] ERROR: Sleeping for 21600 seconds before trying again
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:282:in select': can't convert String into time interval (TypeError) from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:282:in client_sleep'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:263:in run_application' from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in loop'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in run_application' from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application.rb:67:in run'
from /usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-client:26
from /usr/bin/chef-client:19:in `load'
from /usr/bin/chef-client:19

10/07 01:12[root@test-dev ~]# head -3 /etc/chef/client.rb
log_level :info
log_location STDOUT
interval "21600"

Still getting rendered as a string here. You want that to appear as:

interval 21600

Please paste the relevant contents of your client.erb template.

Cheers,

–AJ

thoughts?

for shizzles i've tried both

 "interval": "21600",

and

 "interval": 21600,

in my override, like:
"override_attributes": {
"chef_client": {
"init_style": "init",
"interval": "21600",
"server_url": "https://chef.dev.sushimysavior.com",
"validation_client_name": "chef-validator"
}
}

On Fri, 07 Oct 2011, AJ Christensen wrote:

Yo,

Still getting rendered as a string here. You want that to appear as:

interval 21600

Please paste the relevant contents of your client.erb template.

[cheftain01]$ pwd
/home/kallen/sbox/ops/chef-repo/cookbooks/chef-client/templates/default

[cheftain01]$ head client.rb.erb
log_level :info
log_location STDOUT
interval "<%= node["chef_client"]["interval"].to_i %>"

<% if Chef::Config.has_key?(:chef_server_url) -%>
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
<% else -%>
chef_server_url "<%= node["chef_client"]["server_url"] %>"
<% end -%>
validation_client_name "<%= node["chef_client"]["validation_client_name"] %>"

Yo,

On 7 October 2011 14:27, kallen@groknaut.net wrote:

On Fri, 07 Oct 2011, AJ Christensen wrote:

Yo,

Still getting rendered as a string here. You want that to appear as:

interval 21600

Please paste the relevant contents of your client.erb template.

[cheftain01]$ pwd
/home/kallen/sbox/ops/chef-repo/cookbooks/chef-client/templates/default

[cheftain01]$ head client.rb.erb
log_level :info
log_location STDOUT

Ahh..

interval "<%= node["chef_client"]["interval"].to_i %>"

Word, this line is bad. You want it to look like:

interval <%= node["chef_client"]["interval"].to_i %>

Per my original email, without any extra double quotes. :slight_smile:

–AJ

<% if Chef::Config.has_key?(:chef_server_url) -%>
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
<% else -%>
chef_server_url "<%= node["chef_client"]["server_url"] %>"
<% end -%>
validation_client_name "<%= node["chef_client"]["validation_client_name"] %>"

On Fri, 07 Oct 2011, AJ Christensen wrote:

[cheftain01]$ pwd
/home/kallen/sbox/ops/chef-repo/cookbooks/chef-client/templates/default

[cheftain01]$ head client.rb.erb
log_level :info
log_location STDOUT

Ahh..

interval "<%= node["chef_client"]["interval"].to_i %>"

Word, this line is bad. You want it to look like:

interval <%= node["chef_client"]["interval"].to_i %>

Per my original email, without any extra double quotes. :slight_smile:

ahoy! that worked. thanks!

also opened a bug to add that to the cookbook:
http://tickets.opscode.com/browse/COOK-784