Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any thought put into how to handle test_kitchen? More specifically chef_zero. #21

Open
zarry opened this issue Jan 28, 2015 · 2 comments

Comments

@zarry
Copy link
Contributor

zarry commented Jan 28, 2015

I am trying to write some test_kitchen/serverspec tests for my wrapper cookbook that I use internally. I am running into issues with the rundeck::default.rb recipe around likes 91.

Here we check for chef_solo as I don't believe there is good way to check chef_zero. This results in compilation failure when running with chef_zero as it attempts to search the in memory chef server for data bag items that do not exist.

recipients = if Chef::Config[:solo]
        'root'
    elsif node['rundeck']['partial_search']
        partial_search(
        node['rundeck']['mail']['recipients_data_bag'],
        node['rundeck']['mail']['recipients_query'],
            :keys => node['rundeck']['mail']['recipients_keys']
        ).map {|u| u[node['rundeck']['mail']['recipients_keys'].keys.first] }.
        join(',')
    else
        search(node['rundeck']['mail']['recipients_data_bag'], node['rundeck']['mail']['recipients_query']).
        map {|u| eval("u#{node['rundeck']['mail']['recipients_field']}") }.
        join(',')
    end

I have switched to using chef_solo for now, but would prefer using chef_zero in the future. Not entirely sure the best way to handle it. I have thought about adding an attribute that we can just set true/false to tell it weather to search or not but I am not crazy about that, just not sure of another way at the moment.

recipients = if Chef::Config[:solo] || node['rundeck']['test_run']
@priestjim
Copy link
Owner

This can be solved by adding an array node attribute to statically define recipients, that will override the data bag based search if the attribute is not set to nil. Something like node['rundeck']['mail']['recipients'] = ['root']. Does this sound like a good approach to you?

@vitalis
Copy link
Contributor

vitalis commented Apr 25, 2015

All you need is to add local data_bags to .kitchen.yml config, example:

suites:
  - name: rundeck
    data_bags_path: data_bags
    run_list:
      - recipe[rundeck::default]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants