Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awx installation fails when using external postgres due to missing maintenance_db parameter in /usr/bin/launch_awx.sh #5691

Open
kovaxur opened this issue Jan 17, 2020 · 2 comments

Comments

@kovaxur
Copy link

kovaxur commented Jan 17, 2020

ISSUE TYPE
  • Bug Report
SUMMARY

This is closely related to #5221, since that time, now the postgres_db module of ansible has the maintenance_db option, but it's missing from the /usr/bin/launch_awx(_task).sh script.

The problem is the same, as in the previous ticket: when an external postgres db is used, it will try to connect first to the 'postgres' db as it's the default of the maintenance_db variable.

bash-4.2$ source /etc/tower/conf.d/environment.sh

bash-4.2$ ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m postgresql_db --become-user $DATABASE_USER -a "name=$DATABASE_NAME owner=$DATABASE_USER login_user=$DATABASE_USER login_host=$DATABASE_HOST login_password=$DATABASE_PASSWORD port=$DATABASE_PORT" all

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: no pg_hba.conf entry for host "172.22.0.5", user "awx_test", database "postgres", SSL off 127.0.0.1 | FAILED! => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "msg": "unable to connect to database: FATAL: no pg_hba.conf entry for host \"172.22.0.5\", user \"awx_test\", database \"postgres\", SSL off\n" }

ENVIRONMENT
  • AWX version: 9.1.0
  • AWX install method: docker on linux
  • Ansible version: 2.8.4
  • Operating System: Centos7
  • Web Browser: N/A
STEPS TO REPRODUCE
  1. Set an external postgresql server in the environment.sh config file:
    DATABASE_USER=awx_test
    DATABASE_NAME=awx_test
    DATABASE_HOST=XXXXX
    DATABASE_PORT=5432
    DATABASE_PASSWORD=XXXXX

  2. Start the awx_web containers

EXPECTED RESULTS

The reconfiguration of the containers is done without problems.

ACTUAL RESULTS

The initial reconfiguration will fail, as it can't connect to the maintenance_db (postgres by default)

ADDITIONAL INFORMATION

Possible Solution:
Following file should be changed:
installer/roles/image_build/files/launch_awx.sh

From:
ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m postgresql_db --become-user $DATABASE_USER -a "name=$DATABASE_NAME owner=$DATABASE_USER login_user=$DATABASE_USER login_host=$DATABASE_HOST login_password=$DATABASE_PASSWORD port=$DATABASE_PORT" all

To:
ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m postgresql_db --become-user $DATABASE_USER -a "name=$DATABASE_NAME owner=$DATABASE_USER login_user=$DATABASE_USER login_host=$DATABASE_HOST login_password=$DATABASE_PASSWORD port=$DATABASE_PORT maintenance_db=$DATABASE_NAME" all

Or define a DATABASE_MAINTENANCE_DB variable in environment.sh and make it to default to the database name.

Thanks

@kovaxur
Copy link
Author

kovaxur commented Jan 17, 2020

Also affects the same way:
installer/roles/image_build/templates/launch_awx_task.sh.j2

@ryanpetrello
Copy link
Contributor

@kovaxur given that you've prescribed a solution, pull requests are welcome 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants