Created
October 30, 2013 03:32
-
-
Save micgo/7226836 to your computer and use it in GitHub Desktop.
This should fix missing permissions on Enterprise Chef 11 after download/upload operations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'chef/knife' | |
Chef::Config.from_file(File.join(Chef::Knife.chef_config_dir, 'knife.rb')) | |
rest = Chef::REST.new(Chef::Config[:chef_server_url]) | |
Chef::Node.list.each do |node| | |
%w{read update delete grant}.each do |perm| | |
ace = rest.get("nodes/#{node[0]}/_acl")[perm] | |
ace['actors'] << node[0] unless ace['actors'].include?(node[0]) | |
rest.put("nodes/#{node[0]}/_acl/#{perm}", perm => ace) | |
puts "Client \"#{node[0]}\" granted \"#{perm}\" access on node \"#{node[0]}\"" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment