Skip to content
Snippets Groups Projects
Commit 7aa9db8b authored by Ian Baum's avatar Ian Baum
Browse files

Add Attributes Chef handler

Generate a json file containing whitelisted attributes that should
be available to non-root users
parent ebb10b6e
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,11 @@
PG_HASH_PATTERN ||= /\{(.*)\}/
# Attributes which should be considered safe for other services to know
SAFE_ATTRIBUTES = %w(
data_dir
).freeze
def initialize(node)
@node = node
end
......@@ -227,6 +232,12 @@
raise NotImplementedError
end
def safe_attributes
node['gitlab'][service_name].select do |key, value|
SAFE_ATTRIBUTES.include?(key)
end
end
private
def stringify_hash_values(options)
......
......@@ -28,4 +28,15 @@
$stderr.puts
end
end
class Attributes < Chef::Handler
# Generate a JSON file of attributes which non-root users need access to
def report
File.open('/var/opt/gitlab/safe_attributes.json', 'w', 0644) do |file|
[PgHelper].each do |help|
file.puts help.send(:new, node).safe_attributes.to_json
end
end
end
end
end
......@@ -9,6 +9,7 @@
cookbook_path CURRENT_PATH
cache_path "#{CURRENT_PATH}/cache"
exception_handlers << GitLabHandler::Exception.new
report_handlers << GitLabHandler::Attributes.new
verbose_logging false
ssl_verify_mode :verify_peer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment