Commit b45c1965b2bca7dc9948982d8947f7258bf62e89
Committed by
Earth Ugat

1 parent
625534de
Version v0.1.1. Add rescue block for nonexistent databags.
Showing
4 changed files
with
32 additions
and
11 deletions
@@ -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 |