Commit b45c1965b2bca7dc9948982d8947f7258bf62e89

Authored by nollieheel
Committed by Earth Ugat
1 parent 625534de

Version v0.1.1. Add rescue block for nonexistent databags.

@@ -16,5 +16,6 @@ Gemfile.lock @@ -16,5 +16,6 @@ Gemfile.lock
16 bin/* 16 bin/*
17 .bundle/* 17 .bundle/*
18 18
  19 +.chef
19 .kitchen/ 20 .kitchen/
20 .kitchen.local.yml 21 .kitchen.local.yml
  1 +## 0.1.1 - 2016-12-07
  2 +### Fixed
  3 +- Add a rescue block to catch exceptions if the designated data_bags do not exist.
  4 +
1 ## 0.1.0 - 2016-11-16 5 ## 0.1.0 - 2016-11-16
2 ### Added 6 ### Added
3 - Initial release of cfe-users cookbook. 7 - Initial release of cfe-users cookbook.
@@ -4,7 +4,7 @@ maintainer_email 'sysadmin@chromedia.com' @@ -4,7 +4,7 @@ maintainer_email 'sysadmin@chromedia.com'
4 license 'Apache License' 4 license 'Apache License'
5 description 'Simplifies setting up of users in Linux servers.' 5 description 'Simplifies setting up of users in Linux servers.'
6 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7 -version '0.1.0' 7 +version '0.1.1'
8 8
9 depends 'users', '~> 4.0.1' 9 depends 'users', '~> 4.0.1'
10 depends 'sudo', '~> 3.1.0' 10 depends 'sudo', '~> 3.1.0'
@@ -18,18 +18,34 @@ @@ -18,18 +18,34 @@
18 # limitations under the License. 18 # limitations under the License.
19 # 19 #
20 20
21 -users_manage node['cfe-users']['group'] do  
22 - group_id node['cfe-users']['gid']  
23 - data_bag node['cfe-users']['data_bag']  
24 - action [:remove, :create] 21 +begin
  22 + bag = data_bag(node['cfe-users']['data_bag'])
  23 +
  24 + users_manage node['cfe-users']['group'] do
  25 + group_id node['cfe-users']['gid']
  26 + data_bag node['cfe-users']['data_bag']
  27 + action [:remove, :create]
  28 + end
  29 +rescue Net::HTTPServerException, Chef::Exceptions::InvalidDataBagPath
  30 + log "No data bag #{node['cfe-users']['data_bag']} found" do
  31 + level :warn
  32 + end
25 end 33 end
26 34
27 -users_manage node['cfe-users']['admin_group'] do  
28 - group_id node['cfe-users']['admin_gid']  
29 - data_bag node['cfe-users']['admin_data_bag']  
30 - action [:remove, :create]  
31 - if node['cfe-users']['post_run_reboot']  
32 - notifies :request_reboot, 'reboot[reboot_after_admin_users]' 35 +begin
  36 + bag = data_bag(node['cfe-users']['admin_data_bag'])
  37 +
  38 + users_manage node['cfe-users']['admin_group'] do
  39 + group_id node['cfe-users']['admin_gid']
  40 + data_bag node['cfe-users']['admin_data_bag']
  41 + action [:remove, :create]
  42 + if node['cfe-users']['post_run_reboot']
  43 + notifies :request_reboot, 'reboot[reboot_after_admin_users]'
  44 + end
  45 + end
  46 +rescue Net::HTTPServerException, Chef::Exceptions::InvalidDataBagPath
  47 + log "No data bag #{node['cfe-users']['admin_data_bag']} found" do
  48 + level :warn
33 end 49 end
34 end 50 end
35 51