Awx: docker-compose install gets "no pg_hba.conf entry"

Created on 13 Sep 2019  Â·  30Comments  Â·  Source: ansible/awx

ISSUE TYPE
  • Bug Report
SUMMARY

Standard docker install fails to work.

ENVIRONMENT
  • AWX version: latest (60fc952)
  • AWX install method: docker on linux
  • Ansible version: 2.8.4
  • Operating System: CentOS 3.10.0-957.el7.x86_64
  • Web Browser: n/a
STEPS TO REPRODUCE

Standard git pull, from awx/installer, run sudo ansible-playbook -i inventory install.yml

EXPECTED RESULTS

A working AWX install

ACTUAL RESULTS

From the docker logs of the postgres image, I see lots of these:
no pg_hba.conf entry for host

The location as per the docker-compose is:
PGDATA: /var/lib/postgresql/data/pgdata
with the volume mapped as:
- /tmp/pgdocker/10/data/:/var/lib/postgresql/data/pgdata:Z
Running inside the container:
cat $PGDATA/pg_hba.conf works

So postgres is looking for another location? Will keep running tests to see if I can figure out where it is trying to pull from.

ADDITIONAL INFORMATION
installer medium needs_devel bug

Most helpful comment

Why is this issue closed? This is happening again all the time. Tested on the latest version.

All 30 comments

@shanemcd @rooftopcellist is this related to the recent postgres10 update?

Ok, got the fix, I think.
Based the solution from here: https://github.com/docker-library/postgres/issues/482
Added the following line to pg_hba.conf

host all all 0.0.0.0/0 trust

NOTE: no idea if this is kosher.
Then did a

docker-compose restart

Ok, reading from here: https://github.com/kartoza/docker-postgis/issues/83

It looks like we should be able to fix the issue by adding the following line to
https://github.com/ansible/awx/blob/devel/installer/roles/local_docker/templates/docker-compose.yml.j2
in the postgres section

ALLOW_IP_RANGE: 0.0.0.0/0

However, doing that doesn't seem to fix the issue. Wondering if it is that issue mentioned in that ticket.
Thus, the band-aid solution is to do the above, namely manually edit the pg_hba.conf file and then restart.

Has anyone successfully worked around the pg_hba.conf issue and gotten AWX to deploy on a local docker? I've tried but now I'm getting messages about the awx and postgres databases not existing.

@treyd @javexed This looks to be fixed now. I just did a fresh install of Local AWX and was unable to reproduce this. (ansible-playbook -i inventory install.yml)

@treyd can you try with the latest code, and share any tracebacks you of seeing in the logs?

@javexed are you still seeing this issue?

Yes, I am still having this problem. I am on the latest devel branch, and I also tried building locally with the ansible-playbook -i inventory build.yml command.

Here is the traceback in the awx_task logs:

2019-10-25 15:29:30,182 INFO success: dispatcher entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Traceback (most recent call last):
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
    self.connect()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  no pg_hba.conf entry for host "172.27.0.6", user "awx", database "awx", SSL off


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/awx-manage", line 11, in <module>
    load_entry_point('awx==8.0.0.0', 'console_scripts', 'awx-manage')()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/__init__.py", line 158, in manage
    execute_from_command_line(sys.argv)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/run_dispatcher.py", line 123, in handle
    reaper.reap()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/dispatch/reaper.py", line 38, in reap
    (changed, me) = Instance.objects.get_or_register()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/managers.py", line 134, in get_or_register
    return (False, self.me())
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/managers.py", line 114, in me
    if node.exists():
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/models/query.py", line 766, in exists
    return self.query.has_results(using=self.db)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/models/sql/query.py", line 522, in has_results
    return compiler.has_results()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/models/sql/compiler.py", line 1070, in has_results
    return bool(self.execute_sql(SINGLE))
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/models/sql/compiler.py", line 1098, in execute_sql
    cursor = self.connection.cursor()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 256, in cursor
    return self._cursor()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 233, in _cursor
    self.ensure_connection()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
    self.connect()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
    self.connect()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL:  no pg_hba.conf entry for host "172.27.0.6", user "awx", database "awx", SSL off

2019-10-25 15:29:32,645 INFO exited: dispatcher (exit status 1; not expected)

Also, when I edit pg_hba.conf to allow connections from 0.0.0.0/0 I get the following in the logs:

```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OperationalError: FATAL: database "postgres" does not exist
127.0.0.1 | FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"msg": "unable to connect to database: FATAL: database \"postgres\" does not exist\n"
}
Traceback (most recent call last):
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
connection = Database.connect(*conn_params)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, *
kwasync)
psycopg2.OperationalError: FATAL: database "awx" does not exist

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/bin/awx-manage", line 11, in
load_entry_point('awx==8.0.0.0', 'console_scripts', 'awx-manage')()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/__init__.py", line 158, in manage
execute_from_command_line(sys.argv)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(args, cmd_options)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(
args, *options)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(
args, *kwargs)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/commands/migrate.py", line 87, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
if self.has_table():
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 256, in cursor
return self._cursor()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 233, in _cursor
self.ensure_connection()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
connection = Database.connect(
conn_params)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, *
kwasync)
django.db.utils.OperationalError: FATAL: database "awx" does not exist```

@treyd Is this a fresh install? If it is in an upgrade scenario, my hunch is that this could be the culprit: https://github.com/ansible/awx/blob/70057bc0f26318cd516f5c05aa1d36f0570c577d/installer/roles/local_docker/tasks/main.yml#L42

Some of the settings from postgresql9.6 may not be compatible with postgres10 as is.

I am trying to reproduce this locally. If it is possible for you to share your pg_hba.conf or the relevant sections, that might be useful.

This is a fresh install. I have also tried running the install after checking out tags 8.0.0 and 7.0.0. All seem to use postgres:10 and exhibit the same behavior.

Here is my pg_hba.conf:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             0.0.0.0/0            trust    # <--- I changed this from 127.0.0.1/32
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

I just did a fresh install and built images locally as you did (build.yml, then install.yml with the dockerhub line commented out in the inventory file) and it was successful.

I should mention that I deleted all old awx containers before doing so (since you are seeing postgresql10, this is probably not your issue, but it doesn't hurt).

This is the pg_hba.conf in the resulting awx_postgres container:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

host all all all md5

Postgresql 10 does not allow passwords in plain-text for pg users iirc. You might try adding that last line to your pg_hba.conf and giving it a go. Let me know if that helps or not.

Will try again and let you know.

@rooftopcellist I am still getting the below error. This after completely blowing away my repo checkout, making sure there is no ~/.awx/, deleting all local images and commenting out dockerhub_base, I completely rebuilt all the images with build.yml and then did an install using install.yml'. Thepg_hba.confdoes have thehost all all all md5` so that is a change, but I still can't launch AWX on my local docker machine.

Using /etc/ansible/ansible.cfg as config file
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OperationalError: FATAL:  database "postgres" does not exist
127.0.0.1 | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "msg": "unable to connect to database: FATAL:  database \"postgres\" does not exist\n"
}
Traceback (most recent call last):
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
    self.connect()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  database "awx" does not exist


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/awx-manage", line 11, in <module>
    load_entry_point('awx==8.0.0.0', 'console_scripts', 'awx-manage')()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/__init__.py", line 158, in manage
    execute_from_command_line(sys.argv)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/commands/migrate.py", line 87, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
    if self.has_table():
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/recorder.py", line 56, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 256, in cursor
    return self._cursor()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 233, in _cursor
    self.ensure_connection()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
    self.connect()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
    self.connect()
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL:  database "awx" does not exist

To get around the connection failure error:

echo "host    all             all             172.18.0.0/24           md5" >> ~/.awx/pgdocker/10/data/pg_hba.conf

This still leaves you with a missing database (or any initialization whatsoever) inside the postgres container, which is the error @treyd reported just above. Trying to work that one out.

So, in addition to the above pg_hba.conf modification, what I had to do extra to get the DB initialized was:

docker  exec  -t awx_postgres createdb --user awx awx
cd ~/.awx/awxcompose/
docker-compose restart postgres
docker-compose restart task

@gtie this worked for me, thanks!

Sounds like the install.yml playbook needs to do this? Or maybe this is something that should be done from the docker-compose context?

The pg_hba line is conditional on the usage of docker-compose. So, that file needs to be templetized, rather than copied (as it is now), and the extra line needs to be made conditional on the type of installation.

The DB initialization needs more debugging to see how to best fix it. The commands above are a hack.

Ok, redid my steps and the error is gone and AWX is installed correctly without the need for the additional hacks. Thank you!

I’d like to reopen this issue since exactly the error described above happened to me while trying to deploy awx on a fresh centos7. After running the install.yml playbook, the message FATAL: no pg_hba.conf appears multiple times in the awx_task container logs.

I could solve the problem by appending manually the following line in /root/.awx/pgdocker/10/data/pg_hba.conf:

host all all all trust

This is for sure a security nightmare, but it works. The docker container for postgres:10 has a parameter to configure the pg_hba.conf file: POSTGRES_HOST_AUTH_METHOD. Maybe this parameter can be used to configure postgres correctly?

Ok, got the fix, I think.
Based the solution from here: docker-library/postgres#482
Added the following line to pg_hba.conf

host all all 0.0.0.0/0 trust

NOTE: no idea if this is kosher.
Then did a

docker-compose restart

Thanks, it helped

Why is this issue closed? This is happening again all the time. Tested on the latest version.

I closed it because I was asked to restest... .and it worked at that time.
:)

Let me try again.

On Thu, May 28, 2020 at 5:24 AM Arjon Bujupi notifications@github.com
wrote:

Why is this issue closed? This is happening again all the time. Tested on
the latest version.

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/ansible/awx/issues/4736#issuecomment-635226630, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ABVZFIFGPOKGGRDUTFQWRFDRTYUVPANCNFSM4IWL3T4Q
.

@ArjonBu Have you tried on a linux system ?

For any reason I tried to install it on my mac with docker deployment and I hit this issue as well.

I switched to centos and I didn't have any issues. (Using AWX release 11.2.0)

Happening to me with new AWX 13.0.0 release and also on macOS using docker-compose install method.

I'm trying to install AWX 13.0.0 right now. On Mac OS as well as using docker-compose install method, as @neutralrockets did and i'm getting the same issue here. I can workaround but this issues still exists. Please consider adding a proper hba config.

Just tried installing AWX 13.0.0 on a ubuntu 20.04 VM using docker-compose.

Same issue.

This is is happening to me on Mac OS AWX 13.0.0
2020-07-15 20:50:05,253 WARNING awx.main.dispatch.periodic periodic beat started
Traceback (most recent call last):
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
connection = Database.connect(*conn_params)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, *
kwasync)
psycopg2.OperationalError: FATAL: no pg_hba.conf entry for host "172.22.0.4", user "awx", database "awx", SSL off

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/bin/awx-manage", line 8, in
sys.exit(manage())
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/__init__.py", line 154, in manage
execute_from_command_line(sys.argv)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(args, cmd_options)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(
args, *options)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/management/commands/run_dispatcher.py", line 55, in handle
reaper.reap()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/dispatch/reaper.py", line 38, in reap
(changed, me) = Instance.objects.get_or_register()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/managers.py", line 144, in get_or_register
return (False, self.me())
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/managers.py", line 100, in me
if node.exists():
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py", line 766, in exists
return self.query.has_results(using=self.db)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/query.py", line 522, in has_results
return compiler.has_results()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1110, in has_results
return bool(self.execute_sql(SINGLE))
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1138, in execute_sql
cursor = self.connection.cursor()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py", line 256, in cursor
return self._cursor()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py", line 233, in _cursor
self.ensure_connection()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
connection = Database.connect(
conn_params)
File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, *
kwasync)
django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host "172.22.0.4", user "awx", database "awx", SSL off

I just tried this as well on macOS (10.15.5) and am hitting the same error. All three of the awx_task, awx_web, and awx_postgres containers' logs are full of messages like:

2020-07-21 19:37:29.174 UTC [4677] FATAL:  no pg_hba.conf entry for host "172.18.0.5", user "awx", database "awx", SSL off

And:

django.db.utils.OperationalError: FATAL:  no pg_hba.conf entry for host "172.18.0.5", user "awx", database "awx", SSL off

I'm running from devel, clean environment that was just completely reset with docker system prune (so no images in cache and no pre-existing installations were present).

Attempts to fix

I commented out the dockerhub_base=ansible line in the inventory file and re-built everything, so it built the task and web images locally, and that seemed to get the installation further. Now I'm seeing in the database logs:

2020-07-21 20:06:05.259 UTC [2051] FATAL:  database "awx" does not exist

So then I followed @gtie's instructions earlier in the thread to initialize the database manually:

docker exec -t awx_postgres createdb --user awx awx
cd ~/.awx/awxcompose/
docker-compose restart postgres
docker-compose restart task

And now I'm finally getting the 'AWX is upgrading' screen and seeing the initialization process complete.

Debugging

It looks like the generated docker-compose.yml file config is correct, setting the right things for POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB. Maybe it's an issue with the shared volume and permissions, or an issue with the postgres image on Docker Hub?

After reading through this issue (https://github.com/docker-library/postgres/issues/696), it seems like the recommendation is to mount a volume into the default path /var/lib/postgresql/data, but the templated Docker Compose file has the volume at the path /var/lib/postgresql/data/pgdata (with the PGDATA environment var set to the same).

I modified the docker-compose.yml file to use the default path, reset my environment, and rebuilt it, and it looks like it's working. That didn't work. Had to run the manual steps above again. But it would still be nice to use the default path, IMO.

Why is this issue closed? The project doesn't start!

The fixes described by gtie look nice... but AWX now shows Server Error and the docker logs are filled with errors, like:
awx_task | psycopg2.OperationalError: FATAL: no pg_hba.conf entry for host "172.21.0.5", user "awx", database "awx", SSL off

Docker-compose method, on macOS 10.15.5, AWX version 14.0.0

@johntellsall - please see https://github.com/ansible/awx/issues/7699

Hi all,
@geerlingguy I have the same issue on Ubuntu 18.04.05. So it is not a MacOs related issue as it is suggested by the #7699 ticket.
I did 4 installations with docker compose of AWX, each time on a fresh install of the same Ubuntu version.
For 2 of them, AWX server was fully working after the docker compose installation.
For the 2 others, I got the error described here ( no pg_hba.conf entry for host "172.27.0.5", user "awx", database "awx").
So it seems there is something "random" in this issue. And so it is not because one test passes that we can close the issue from my point of view.

I solved the issue by removing the pg_data directory and restart docker-compose. The second time this line appears in the pg_hba.conf file

host    all     all     172.18.0.5/32       trust
Was this page helpful?
0 / 5 - 0 ratings