vagrant works
This commit is contained in:
@ -22,7 +22,7 @@ module PostgresqlCookbook
|
||||
require 'securerandom'
|
||||
|
||||
def psql_command_string(new_resource, query, grep_for: nil, value_only: false)
|
||||
cmd = "/usr/bin/psql -c \"#{query}\""
|
||||
cmd = %(/usr/bin/psql -c "#{query}")
|
||||
cmd << " -d #{new_resource.database}" if new_resource.database
|
||||
cmd << " -U #{new_resource.user}" if new_resource.user
|
||||
cmd << " --host #{new_resource.host}" if new_resource.host
|
||||
@ -35,12 +35,12 @@ module PostgresqlCookbook
|
||||
def execute_sql(new_resource, query)
|
||||
# If we don't pass in a user to the resource
|
||||
# default to the postgres user
|
||||
user = new_resource.user ? new_resource.user : 'postgres'
|
||||
user = new_resource.user || 'postgres'
|
||||
|
||||
# Query could be a String or an Array of Strings
|
||||
statement = query.is_a?(String) ? query : query.join("\n")
|
||||
|
||||
cmd = shell_out(statement, user: user)
|
||||
cmd = shell_out(statement, user: user, environment: psql_environment)
|
||||
|
||||
# Pass back cmd so we can decide what to do with it in the calling method.
|
||||
cmd
|
||||
@ -81,7 +81,7 @@ module PostgresqlCookbook
|
||||
end
|
||||
|
||||
def create_extension_sql(new_resource)
|
||||
sql = "CREATE EXTENSION IF NOT EXISTS #{new_resource.extension}"
|
||||
sql = %(CREATE EXTENSION IF NOT EXISTS #{new_resource.extension})
|
||||
sql << " FROM \"#{new_resource.old_version}\"" if new_resource.old_version
|
||||
|
||||
psql_command_string(new_resource, sql)
|
||||
@ -239,6 +239,12 @@ module PostgresqlCookbook
|
||||
platform?('amazon') ? '6' : '$releasever'
|
||||
end
|
||||
|
||||
# Fedora doesn't seem to know the right symbols for psql
|
||||
def psql_environment
|
||||
return {} unless platform?('fedora')
|
||||
{ LD_LIBRARY_PATH: '/usr/lib64' }
|
||||
end
|
||||
|
||||
# Generate a password if the value is set to generate.
|
||||
def postgres_password(new_resource)
|
||||
new_resource.password == 'generate' ? secure_random : new_resource.password
|
||||
|
Reference in New Issue
Block a user