From 6a90c9cfaa5609529645c314d4fe38e3e4d33e10 Mon Sep 17 00:00:00 2001 From: Nick Carboni Date: Thu, 5 Jan 2017 15:01:14 -0500 Subject: [PATCH 1/2] Create awx database and user when vmdb is created --- .../appliance_console/internal_database_configuration.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/gems/pending/appliance_console/internal_database_configuration.rb b/lib/gems/pending/appliance_console/internal_database_configuration.rb index c4f8bdf01..58e4bfcd4 100644 --- a/lib/gems/pending/appliance_console/internal_database_configuration.rb +++ b/lib/gems/pending/appliance_console/internal_database_configuration.rb @@ -136,11 +136,13 @@ def create_postgres_root_user conn = PG.connect(:user => "postgres", :dbname => "postgres") esc_pass = conn.escape_string(password) conn.exec("CREATE ROLE #{username} WITH LOGIN CREATEDB SUPERUSER PASSWORD '#{esc_pass}'") + conn.exec("CREATE ROLE awx WITH LOGIN PASSWORD '#{esc_pass}'") end def create_postgres_database conn = PG.connect(:user => "postgres", :dbname => "postgres") conn.exec("CREATE DATABASE #{database} OWNER #{username} ENCODING 'utf8'") + conn.exec("CREATE DATABASE awx OWNER awx ENCODING 'utf8'") end def relabel_postgresql_dir From 16baf8132809b0addafb7c07a88f87b3333d3bc5 Mon Sep 17 00:00:00 2001 From: Nick Carboni Date: Fri, 20 Jan 2017 12:51:09 -0500 Subject: [PATCH 2/2] Print the host, port, and password even when configuring a local database This will allow us to access the database information for ansible which does not use local sockets for "external" databases. This will also allow failover to work properly when going from a local database to a remote one. --- .../pending/appliance_console/database_configuration.rb | 6 +++--- spec/appliance_console/database_configuration_spec.rb | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/gems/pending/appliance_console/database_configuration.rb b/lib/gems/pending/appliance_console/database_configuration.rb index bc27647d3..693b7dc4d 100644 --- a/lib/gems/pending/appliance_console/database_configuration.rb +++ b/lib/gems/pending/appliance_console/database_configuration.rb @@ -150,10 +150,10 @@ def friendly_inspect def settings_hash { 'adapter' => 'postgresql', - 'host' => local? ? nil : host, - 'port' => local? ? nil : port, + 'host' => local? ? "localhost" : host, + 'port' => port, 'username' => username, - 'password' => local? ? nil : password.presence, + 'password' => password.presence, 'database' => database } end diff --git a/spec/appliance_console/database_configuration_spec.rb b/spec/appliance_console/database_configuration_spec.rb index 98a9ab48c..4034127a9 100644 --- a/spec/appliance_console/database_configuration_spec.rb +++ b/spec/appliance_console/database_configuration_spec.rb @@ -323,12 +323,6 @@ def say(*_args) context "#merged_settings" do subject { @config.merged_settings["production"] } - it "should remove host/password from previous values for localhost" do - @config.host = "localhost" - @config.port = "123" - expect(subject).not_to include("host", "port", "password") - end - it "should inherit unchanged non-core values" do expect(subject).to include("encoding" => "utf8", "pools" => "5") end