Skip to content

Commit ae0878a

Browse files
authored
Add more METRICS_UTILITY_DB_ env vars, warn if present in controller venv (#359)
* Add more METRICS_UTILITY_DB_ env vars, warn if present in controller mode * Makefile: add podman-compose variants
1 parent e341975 commit ae0878a

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,14 @@ clean:
2929
psql:
3030
${CONTAINER_ENGINE} compose -f tools/docker/docker-compose.yaml exec postgres psql -U awx
3131

32-
.PHONY: help sync test coverage lint fix compose clean psql
32+
pcompose:
33+
podman-compose -f tools/docker/docker-compose.yaml up
34+
35+
pclean:
36+
podman-compose -f tools/docker/docker-compose.yaml down -v
37+
38+
ppsql:
39+
podman-compose -f tools/docker/docker-compose.yaml exec postgres psql -U awx
40+
41+
42+
.PHONY: help sync test coverage lint fix compose clean psql pcompose pclean ppsql

metrics_utility/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ def prepare():
1919
mock_path = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'mock_awx'))
2020
sys.path.append(mock_path)
2121

22+
db_env_vars = [key for key in os.environ if key.startswith('METRICS_UTILITY_DB_')]
23+
if spec is not None and db_env_vars:
24+
sys.stderr.write(
25+
f'Warning: {", ".join(db_env_vars)} ignored because Automation Controller modules were found. '
26+
'These only take effect in standalone mode.\n'
27+
)
28+
2229
import django
2330

2431
from awx import prepare_env

mock_awx/settings/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
DATABASES = {
55
'default': {
66
'ENGINE': 'django.db.backends.postgresql',
7-
'NAME': 'awx',
8-
'USER': 'myuser',
9-
'PASSWORD': 'mypassword',
7+
'NAME': os.getenv('METRICS_UTILITY_DB_NAME', 'awx'),
8+
'USER': os.getenv('METRICS_UTILITY_DB_USER', 'myuser'),
9+
'PASSWORD': os.getenv('METRICS_UTILITY_DB_PASSWORD', 'mypassword'),
1010
'HOST': os.getenv('METRICS_UTILITY_DB_HOST', 'localhost'),
11-
'PORT': '5432',
11+
'PORT': os.getenv('METRICS_UTILITY_DB_PORT', '5432'),
1212
},
1313
# metrics-service database — same Postgres instance, different DB name/credentials.
1414
# Override any of these via environment variables:
@@ -26,6 +26,7 @@
2626
'PORT': os.getenv('METRICS_SERVICE_DB_PORT', '5432'),
2727
},
2828
}
29+
2930
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
3031
INSTALLED_APPS = ['awx.conf']
3132
LANGUAGE_CODE = 'en-us'

0 commit comments

Comments
 (0)