Skip to content

Commit

Permalink
database: Support SSL connection for db_maker user from ruby library
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuchome committed Sep 20, 2017
1 parent 35f98f9 commit b097a03
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions chef/cookbooks/database/libraries/provider_database_mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,21 @@ def schema_present?(database_name)
end

def client
@client ||= Mysql2::Client.new(
client_options = {
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
)
}
if new_resource.connection[:ssl][:enabled]
if new_resource.connection[:ssl][:insecure]
client_options[:sslverify] = false
else
client_options[:sslca] = new_resource.connection[:ssl][:ca_certs]
end
end
@client ||= Mysql2::Client.new(client_options)
end

def close_client
Expand Down
12 changes: 10 additions & 2 deletions chef/cookbooks/database/libraries/provider_database_mysql_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,21 @@ def user_present?(username, host)
end

def client
@client ||= Mysql2::Client.new(
client_options = {
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
)
}
if new_resource.connection[:ssl][:enabled]
if new_resource.connection[:ssl][:insecure]
client_options[:sslverify] = false
else
client_options[:sslca] = new_resource.connection[:ssl][:ca_certs]
end
end
@client ||= Mysql2::Client.new(client_options)
end

def close_client
Expand Down

0 comments on commit b097a03

Please sign in to comment.