chef-rundeck icon indicating copy to clipboard operation
chef-rundeck copied to clipboard

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

Open zarry opened this issue 10 years ago • 2 comments

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']

zarry avatar Jan 28 '15 22:01 zarry

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?

priestjim avatar Feb 05 '15 06:02 priestjim

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]

vitalis avatar Apr 25 '15 14:04 vitalis