- From: Arnold Krille <
>
- To:
- Subject: [chef] Re: Re: Trouble with ntp-cookbook
- Date: Fri, 13 Dec 2013 15:36:36 +0100
Bump, anybody can look at this and tell me what I did wrong?
Am Wed, 11 Dec 2013 14:40:39 +0100
schrieb Arnold Krille
<
>:
>
I haven't solved this but created a fork+branch at
>
https://github.com/kampfschlaefer/ntp/tree/spec_check_for_content
>
>
Am Wed, 11 Dec 2013 13:54:34 +0100 schrieb Arnold Krille
>
<
>:
>
> I created a small wrapper-cookbook for the ntp-cookbook. This
>
> wrapper searches for non-virtual machines in the current
>
> environment that have the wrapper-cookbook applied. Then it uses
>
> these machines as peers for ntp if itself is a non-virtual machine
>
> or as servers for ntp if itself is a virtual machine. Works great
>
> except for some slight problem: The list of peers/servers is in the
>
> order the search returned the machines, which changes with each
>
> call. I tried to sort my resulting list, but still the lists in the
>
> ntp.conf are not ordered. And the ordering in the ntp.conf changes
>
> with almost every chef-client run, resulting in fcheck finding lots
>
> of changes.
>
>
>
> So I took a quick hack and added ordering in the ntp.conf-template
>
> in the ntp-cookbook. Works nicely in reality but is untested.
>
>
>
> So I tried to prepare a real patch for the ntp-cookbook with
>
> corresponding rspec-test. But when I try to check
>
> "create_file_with_content" I get an error:
>
>
>
> Failure/Error: expect(chef_run).to
>
> create_file_with_content('/etc/ntp.conf', /.*Chef.*/)
>
> Chef::Mixin::Template::TemplateError: undefined method `[]' for
>
> nil:NilClass
>
>
>
> And I don't know why that error is happening. It looks as if the
>
> rspec tests don't set all the attributes the template needs. But
>
> its only the default tests, so if that fails, either there is an
>
> error in chef/chefspec/tests or the cookbook wouldn't be able to
>
> run on any machine (without setting attributes). The later I
>
> doubt...
>
>
>
> Anyway, what I did is patch spec/unit/recipes/default_spec.rb in the
>
> ntp-cookbook with:
>
>
>
> diff --git a/spec/unit/recipes/default_spec.rb
>
> b/spec/unit/recipes/default_spec.rb index fa9b4f7..4e2ce71 100644
>
> --- a/spec/unit/recipes/default_spec.rb
>
> +++ b/spec/unit/recipes/default_spec.rb
>
> @@ -1,4 +1,5 @@
>
> require 'spec_helper'
>
> +require 'chefspec'
>
>
>
> describe 'ntp::default' do
>
> let(:chef_run)
>
> { ChefSpec::ChefRunner.new.converge('ntp::default') } @@ -69,6
>
> +70,10 @@ describe 'ntp::default' do expect(chef_run).to
>
> create_file('/etc/ntp.conf') end
>
>
>
> + it 'creates the template with peer content' do
>
> + expect(chef_run).to
>
> create_file_with_content('/etc/ntp.conf', /.*Chef.*/)
>
> + end
>
> +
>
> it 'is owned by ntp:ntp' do
>
> expect(template.owner).to eq('root')
>
> expect(template.group).to eq('root')
>
>
>
> Anybody got an idea? Anybody can reproduce my findings?
>
>
>
> I use ruby-2.0.0-p247 and everything else according to the Gemfile
>
> of the ntp-cookbook.
>
>
>
> Thanks in advance,
>
> - Arnold
Archive powered by MHonArc 2.6.16.