diff --git a/installer/inventory b/installer/inventory index 58c38ca250..d1a742d314 100644 --- a/installer/inventory +++ b/installer/inventory @@ -30,7 +30,7 @@ awx_secret_key=awxsecret # kubernetes_context=test-cluster # awx_kubernetes_namespace=awx -# Standalone Docker Install +# Common Docker parameters postgres_data_dir=/tmp/pgdocker host_port=80 @@ -38,11 +38,19 @@ host_port=80 # Optional for Openshift if using Dockerhub or another prebuilt registry # Required for Standalone Docker Install if building the image on your own # Optional for Standalone Docker Install if using Dockerhub or another prebuilt registry +# Required for Docker Compose Install if building the image on your own +# Optional for Docker Compose Install if using Dockerhub or another prebuilt registry # Define if you want the image pushed to a registry. The container definition will also use these images # docker_registry=172.30.1.1:5000 # docker_registry_repository=awx # docker_registry_username=developer +# Docker Compose Install +# use_docker_compose=false +# The docker_compose.yml file will be created in this directory +# The name of the directory (here "awx") will be the prefix of the docker containers +docker_compose_dir=/var/lib/awx + # Docker_image will not attempt to push to remote if the image already exists locally # Set this to true to delete images from docker on the build host so that they are pushed to the remote repository diff --git a/installer/local_docker/tasks/compose.yml b/installer/local_docker/tasks/compose.yml index e69de29bb2..3c581c7b69 100644 --- a/installer/local_docker/tasks/compose.yml +++ b/installer/local_docker/tasks/compose.yml @@ -0,0 +1,14 @@ +--- +- name: Create {{ docker_compose_dir }} directory + file: + path: "{{ docker_compose_dir }}" + state: directory + +- name: Create docker-compose.yml file + template: + src: docker-compose.yml.j2 + dest: "{{ docker_compose_dir }}/docker-compose.yml" + +- name: Start the containers + docker_service: + project_src: "{{ docker_compose_dir }}" diff --git a/installer/local_docker/templates/docker-compose.yml.j2 b/installer/local_docker/templates/docker-compose.yml.j2 new file mode 100644 index 0000000000..05240771d4 --- /dev/null +++ b/installer/local_docker/templates/docker-compose.yml.j2 @@ -0,0 +1,97 @@ +#jinja2: lstrip_blocks: True +version: '2' +services: + + web: + image: {{ awx_web_docker_actual_image }} + depends_on: + - rabbitmq + - memcached + {% if pg_hostname is not defined %} + - postgres + {% endif %} + ports: + - "{{ host_port }}:8052" + hostname: awxweb + user: root + restart: unless-stopped + {% if awx_container_search_domains is defined %} + dns_search: "{{ awx_container_search_domains }}" + {% endif %} + environment: + http_proxy: {{ http_proxy | default('') }} + https_proxy: {{ https_proxy | default('') }} + no_proxy: {{ no_proxy | default('') }} + SECRET_KEY: {{ awx_secret_key }} + DATABASE_NAME: {{ pg_database }} + DATABASE_USER: {{ pg_username }} + DATABASE_PASSWORD: {{ pg_password }} + DATABASE_PORT: {{ pg_port }} + DATABASE_HOST: {{ pg_hostname|default("postgres") }} + RABBITMQ_USER: guest + RABBITMQ_PASSWORD: guest + RABBITMQ_HOST: rabbitmq + RABBITMQ_PORT: 5672 + RABBITMQ_VHOST: awx + MEMCACHED_HOST: memcached + MEMCACHED_PORT: 11211 + AWX_ADMIN_USER: {{ default_admin_user|default('admin') }} + AWX_ADMIN_PASSWORD: {{ default_admin_password|default('password') }} + + task: + image: {{ awx_task_docker_actual_image }} + depends_on: + - rabbitmq + - memcached + - web + {% if pg_hostname is not defined %} + - postgres + {% endif %} + hostname: awx + user: root + restart: unless-stopped + {% if awx_container_search_domains is defined %} + dns_search: "{{ awx_container_search_domains }}" + {% endif %} + environment: + http_proxy: {{ http_proxy | default('') }} + https_proxy: {{ https_proxy | default('') }} + no_proxy: {{ no_proxy | default('') }} + SECRET_KEY: {{ awx_secret_key }} + DATABASE_NAME: {{ pg_database }} + DATABASE_USER: {{ pg_username }} + DATABASE_PASSWORD: {{ pg_password }} + DATABASE_HOST: {{ pg_hostname|default("postgres") }} + DATABASE_PORT: {{ pg_port }} + RABBITMQ_USER: guest + RABBITMQ_PASSWORD: guest + RABBITMQ_HOST: rabbitmq + RABBITMQ_PORT: 5672 + RABBITMQ_VHOST: awx + MEMCACHED_HOST: memcached + MEMCACHED_PORT: 11211 + AWX_ADMIN_USER: {{ default_admin_user|default('admin') }} + AWX_ADMIN_PASSWORD: {{ default_admin_password|default('password') }} + + rabbitmq: + image: rabbitmq:3 + restart: unless-stopped + environment: + RABBITMQ_DEFAULT_VHOST: awx + + memcached: + image: memcached:alpine + restart: unless-stopped + + {% if pg_hostname is not defined %} + postgres: + image: postgres:9.6 + restart: unless-stopped + volumes: + - {{ postgres_data_dir }}:/var/lib/postgresql/data:Z + environment: + POSTGRES_USER: {{ pg_username }} + POSTGRES_PASSWORD: {{ pg_password }} + POSTGRES_DB: {{ pg_database }} + PGDATA: /var/lib/postgresql/data/pgdata + {% endif %}