MrMEEE / awx-build

144 stars 39 forks source link

Configuring AWX #20

Closed terryaclarke closed 5 years ago

terryaclarke commented 6 years ago

Hi,

I want to configure the AWX to use a remote DB. Can you please help me. I need the name of the config file to change, so I can point the AWX to the remote DB.

MrMEEE commented 6 years ago

Hi

Haven't tried it, but can't see why it shouldn't work..

The configuration is in /etc/awx/settings.py..

more specific:

DATABASES = {
    'default': {
        'ATOMIC_REQUESTS': True,
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'awx',
        # 'USER': os.getenv("DATABASE_USER", None),
        # 'PASSWORD': os.getenv("DATABASE_PASSWORD", None),
        # 'HOST': os.getenv("DATABASE_HOST", None),
        # 'PORT': os.getenv("DATABASE_PORT", None),
    }
}
terryaclarke commented 6 years ago

I tries this and it did not work.

DATABASES = { 'default': { 'ATOMIC_REQUESTS': True, 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'awxDB', 'USER': os.getenv("awxDBsrv", None), 'PASSWORD': os.getenv(awxDBsrv1234, None), 'HOST': os.getenv(la2-dev-awx-101.abc.com, None), 'PORT': os.getenv("5432", None), } }

Here is the error:

[root@la2-dev-awx-101 /]# /opt/awx/bin/awx-manage migrate Traceback (most recent call last): File "/opt/awx/bin/awx-manage", line 11, in sys.exit(manage()) File "/opt/awx/embedded/lib/python2.7/site-packages/awx/init.py", line 109 , in manage execute_from_commandline(sys.argv) File "/opt/awx/embedded/lib64/python2.7/site-packages/django/core/management/ _init.py", line 364, in execute_from_commandline utility.execute() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/core/management/ _init.py", line 338, in execute django.setup() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/init.py", lin e 27, in setup apps.populate(settings.INSTALLED_APPS) File "/opt/awx/embedded/lib64/python2.7/site-packages/django/apps/registry.py" , line 116, in populate app_config.ready() File "/opt/awx/embedded/lib/python2.7/site-packages/awx/conf/apps.py", line 18 , in ready configure_external_logger(settings) File "/opt/awx/embedded/lib/python2.7/site-packages/awx/main/utils/handlers.py ", line 342, in configure_external_logger is_enabled = settings_module.LOG_AGGREGATOR_ENABLED File "/opt/awx/embedded/lib/python2.7/site-packages/awx/conf/settings.py", lin e 474, in getattr_without_cache__ return getattr(self._wrapped, name) File "/opt/awx/embedded/lib/python2.7/site-packages/awx/conf/settings.py", lin e 387, in getattr value = self._get_local(name) File "/usr/lib64/python2.7/contextlib.py", line 35, in exit self.gen.throw(type, value, traceback) File "/opt/awx/embedded/lib/python2.7/site-packages/awx/conf/settings.py", lin e 65, in _log_database_error if get_tower_migration_version() < '310': File "/opt/awx/embedded/lib/python2.7/site-packages/awx/main/utils/db.py", lin e 14, in get_tower_migration_version loader = MigrationLoader(connection, ignore_no_migrations=True) File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/migrations/loa der.py", line 52, in init self.build_graph() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/migrations/loa der.py", line 209, in build_graph self.applied_migrations = recorder.applied_migrations() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/migrations/rec order.py", line 65, in applied_migrations self.ensure_schema() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/migrations/rec order.py", line 52, in ensure_schema if self.Migration._meta.db_table in self.connection.introspection.table_name s(self.connection.cursor()): File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/backends/base/ base.py", line 254, in cursor return self._cursor() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/backends/base/ base.py", line 229, in _cursor self.ensure_connection() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/backends/base/ base.py", line 213, in ensure_connection self.connect() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/utils.py", lin e 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/backends/base/ base.py", line 213, in ensure_connection self.connect() File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/backends/base/ base.py", line 189, in connect self.connection = self.get_new_connection(conn_params) File "/opt/awx/embedded/lib64/python2.7/site-packages/django/db/backends/postg resql/base.py", line 176, in get_new_connection connection = Database.connect(**conn_params) File "/opt/awx/embedded/lib64/python2.7/site-packages/psycopg2/init__.py", l ine 130, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) django.db.utils.OperationalError: could not connect to server: No such file or d irectory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

MrMEEE commented 6 years ago

Try this instead:

DATABASES = { 'default': { 'ATOMIC_REQUESTS': True, 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'awxDB', 'USER': 'awxDBsrv', 'PASSWORD': 'awxDBsrv1234', 'HOST': 'la2-dev-awx-101.abc.com', 'PORT': '5432', } }

terryaclarke commented 6 years ago

This is the result. Does this look correct?

[root@la2-dev-awx-101 ~]# /opt/awx/bin/awx-manage migrate Operations to perform: Apply all migrations: auth, conf, contenttypes, django_celery_results, main, sessions, sites, social_django, sso, taggit Running migrations: Applying contenttypes.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0001_initial... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying taggit.0001_initial... OK Applying taggit.0002_auto_20150616_2121... OK Applying main.0001_initial... OK Applying main.0002_squashed_v300_release... OK Applying main.0003_squashed_v300_v303_updates... OK Applying main.0004_squashed_v310_release... OK Applying conf.0001_initial... OK Applying conf.0002_v310_copy_tower_settings... OK Applying conf.0003_v310_JSONField_changes... OK Applying conf.0004_v320_reencrypt... OK Applying django_celery_results.0001_initial... OK Applying main.0005_squashed_v310_v313_updates... OK Applying main.0005a_squashed_v310_v313_updates... OK Applying main.0005b_squashed_v310_v313_updates... OK Applying main.0006_v320_release... OK Applying main.0007_v320_data_migrations...2018-06-15 20:33:33,369 DEBUG awx.main.migrations Removing all Rackspace InventorySource from database. 2018-06-15 20:33:33,669 DEBUG awx.main.migrations Removing all Azure Credentials from database. 2018-06-15 20:33:33,967 DEBUG awx.main.migrations Removing all Azure InventorySource from database. 2018-06-15 20:33:34,265 DEBUG awx.main.migrations Removing all InventorySource that have no link to an Inventory from database. OK Applying main.0008_v320_drop_v1_credential_fields... OK Applying main.0009_v330_multi_credential... OK Applying main.0010_saved_launchtime_configs... OK Applying main.0011_blank_start_args... OK Applying main.0012_non_blank_workflow... OK Applying main.0013_move_deprecated_stdout... OK Applying sessions.0001_initial... OK Applying sites.0001_initial... OK Applying sites.0002_alter_domain_unique... OK Applying social_django.0001_initial... OK Applying social_django.0002_add_related_name... OK Applying social_django.0003_alter_email_max_length... OK Applying social_django.0004_auto_20160423_0400... OK Applying social_django.0005_auto_20160727_2333... OK Applying social_django.0006_partial... OK Applying social_django.0007_code_timestamp... OK Applying social_django.0008_partial_timestamp... OK Applying sso.0001_initial... OK Applying sso.0002_expand_provider_options... OK [root@la2-dev-awx-101 ~]#

terryaclarke commented 6 years ago

I did not get this.

[root@awx ~]# echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'root@localhost', 'password')" | sudo -u awx /opt/awx/bin/awx-manage shell [root@awx ~]# sudo -u awx /opt/awx/bin/awx-manage create_preload_data Default organization added. Demo Credential, Inventory, and Job Template added. [root@awx ~]# sudo -u awx /opt/awx/bin/awx-manage provision_instance --hostname=$(hostname) Successfully registered instance awx.sunil.cc (changed: True) [root@awx ~]# sudo -u awx /opt/awx/bin/awx-manage register_queue --queuename=tower --hostnames=$(hostname) Creating instance group tower Added instance awx.sunil.cc to tower (changed: True) [root@awx ~]#

terryaclarke commented 6 years ago

The web page comes up, but the admin and password don't work.

MrMEEE commented 6 years ago

Can you please check the log file, when you try to login??

/var/log/awx/web.log /var/log/nginx/error_log /var/log/nginx/access_log /var/log/messages

Setup look ok...

Maybe try to create a second user: echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin2', 'root@localhost', 'password')" | sudo -u awx /opt/awx/bin/awx-manage shell

terryaclarke commented 6 years ago

Can you point me to a location I can read documentation concerning awx-manage shell. The help feature is not working. When I enter help to view the help pages, I get nothing back.

I entered echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin2', at the command line and received [root@la2-dev-awx-101 ~]# echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin',

Am I missing something?

There was nothing useful in the messages.log. Here are the others.

web.log

web.log

terryaclarke commented 6 years ago

access.log

MrMEEE commented 6 years ago

You need the complete line: echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin2','root@localhost', 'password')" | sudo -u awx /opt/awx/bin/awx-manage shell

MrMEEE commented 6 years ago

I don't think that there is any more docs than this:

https://docs.ansible.com/ansible-tower/latest/html/administration/tower-manage.html

rthill commented 6 years ago

You may also use simplified command:sudo -u awx awx-manage createsuperuserand follow the prompts. From: notifications@github.comSent: June 16, 2018 2:31 PMTo: awx-build@noreply.github.comReply-to: reply@reply.github.comCc: subscribed@noreply.github.comSubject: Re: [MrMEEE/awx-build] Configuring AWX (#20) You need the complete line: echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin2','root@localhost', 'password')" | sudo -u awx /opt/awx/bin/awx-manage shell

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

MrMEEE commented 6 years ago

@rthill Thanks for the hint :)

terryaclarke commented 6 years ago

Thanks, I was able to login to the awx. I am having another issue. Extremely slow performance when using AWX with external Postgres instance. Any thoughts? When I try to save a change, it display's the working message and then it does not save the changes.

MrMEEE commented 6 years ago

hmmm.. weird.. any errors in the logs?..

I might try to do a test setup, with a external postgresql..

MrMEEE commented 6 years ago

@terryaclarke I now have a test setup here, with two VMs, one running the Postgres and the other one running the rest..

And it's working great... so the good news is that it's working... the bad news is that we have to figure out what's wrong with your setup...

Found any errors in the logs??

rthill commented 6 years ago

@terryaclarke, can you also post the specs of your VMs please. From: notifications@github.comSent: June 20, 2018 1:27 PMTo: awx-build@noreply.github.comReply-to: reply@reply.github.comCc: raoul.thill@gmail.com; mention@noreply.github.comSubject: Re: [MrMEEE/awx-build] Configuring AWX (#20) @terryaclarke I now have a test setup here, with two VMs, one running the Postgres and the other one running the rest.. And it's working great... so the good news is that it's working... the bad news is that we have to figure out what's wrong with your setup... Found any errors in the logs??

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

terryaclarke commented 6 years ago

Is the awx-manage migrate suppose to create the DB during the installation. I am wondering if the DB is setup wrong.

rthill commented 6 years ago

Yrs, the migrate command setups the database schema an requires the database and database user exists. As the createsuperuser command did work, I suppose your database is correctly setup. From: notifications@github.comSent: June 21, 2018 1:26 AMTo: awx-build@noreply.github.comReply-to: reply@reply.github.comCc: raoul.thill@gmail.com; mention@noreply.github.comSubject: Re: [MrMEEE/awx-build] Configuring AWX (#20) Is the awx-manage migrate suppose to create the DB during the installation. I am wondering if the DB is setup wrong.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

MrMEEE commented 5 years ago

Please reopen if problem persists