From 3bfb54d2fde6b0a071b0748f3d6f48ba4aee7b5d Mon Sep 17 00:00:00 2001 From: Shane McDonald Date: Tue, 16 Apr 2019 12:51:28 -0400 Subject: [PATCH] Fix memcached configuration in local Docker installs Related: https://github.com/ansible/awx/issues/3719 Signed-off-by: Shane McDonald --- installer/roles/image_build/files/settings.py | 12 ------------ installer/roles/local_docker/defaults/main.yml | 5 +++++ installer/roles/local_docker/tasks/compose.yml | 2 ++ .../local_docker/templates/credentials.py.j2 | 17 ++++++++++++++--- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/installer/roles/image_build/files/settings.py b/installer/roles/image_build/files/settings.py index d2d2077d76..f8019425c6 100644 --- a/installer/roles/image_build/files/settings.py +++ b/installer/roles/image_build/files/settings.py @@ -99,16 +99,4 @@ CHANNEL_LAYERS = { 'CONFIG': {'url': BROKER_URL}} } - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': '{}:{}'.format(os.getenv("MEMCACHED_HOST", None), - os.getenv("MEMCACHED_PORT", "11211")) - }, - 'ephemeral': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - }, -} - USE_X_FORWARDED_PORT = True diff --git a/installer/roles/local_docker/defaults/main.yml b/installer/roles/local_docker/defaults/main.yml index 35d61eba21..b3c36ed09a 100644 --- a/installer/roles/local_docker/defaults/main.yml +++ b/installer/roles/local_docker/defaults/main.yml @@ -5,9 +5,14 @@ rabbitmq_version: "3.7.4" rabbitmq_image: "ansible/awx_rabbitmq:{{rabbitmq_version}}" rabbitmq_default_vhost: "awx" rabbitmq_erlang_cookie: "cookiemonster" +rabbitmq_host: "rabbitmq" rabbitmq_port: "5672" rabbitmq_user: "guest" rabbitmq_password: "guest" postgresql_version: "9.6" postgresql_image: "postgres:{{postgresql_version}}" + +memcached_host: "memcached" +memcached_port: "11211" + diff --git a/installer/roles/local_docker/tasks/compose.yml b/installer/roles/local_docker/tasks/compose.yml index 0ab8955cec..16171f59a3 100644 --- a/installer/roles/local_docker/tasks/compose.yml +++ b/installer/roles/local_docker/tasks/compose.yml @@ -20,10 +20,12 @@ content: "{{ secret_key }}" dest: "{{ docker_compose_dir }}/SECRET_KEY" mode: 0600 + register: awx_secret_key - name: Start the containers docker_service: project_src: "{{ docker_compose_dir }}" + restarted: "{{ awx_compose_config is changed or awx_secret_key is changed }}" register: awx_compose_start - name: Update CA trust in awx_web container diff --git a/installer/roles/local_docker/templates/credentials.py.j2 b/installer/roles/local_docker/templates/credentials.py.j2 index b7907fa462..ccdd907f03 100644 --- a/installer/roles/local_docker/templates/credentials.py.j2 +++ b/installer/roles/local_docker/templates/credentials.py.j2 @@ -5,15 +5,16 @@ DATABASES = { 'NAME': "{{ pg_database }}", 'USER': "{{ pg_username }}", 'PASSWORD': "{{ pg_password }}", - 'HOST': "{{ pg_hostname|default('postgres') }}", + 'HOST': "{{ pg_hostname | default('postgres') }}", 'PORT': "{{ pg_port }}", } } + BROKER_URL = 'amqp://{}:{}@{}:{}/{}'.format( "{{ rabbitmq_user }}", "{{ rabbitmq_password }}", - "rabbitmq", - "5672", + "{{ rabbitmq_host }}", + "{{ rabbitmq_port }}", "awx") CHANNEL_LAYERS = { @@ -21,3 +22,13 @@ CHANNEL_LAYERS = { 'ROUTING': 'awx.main.routing.channel_routing', 'CONFIG': {'url': BROKER_URL}} } + +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', + 'LOCATION': '{}:{}'.format("{{ memcached_host }}", "{{ memcached_port }}") + }, + 'ephemeral': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + }, +}