diff --git a/baker/ansible/tasks/product/test.yaml b/baker/ansible/tasks/product/test.yaml index 06b263e1..75b67b37 100644 --- a/baker/ansible/tasks/product/test.yaml +++ b/baker/ansible/tasks/product/test.yaml @@ -5,6 +5,14 @@ changed_when: false when: hostvars.db.image_status|default({}) is changed +- name: Create network + ansible.builtin.shell: + cmd: >- + docker network inspect {{ product.name }} + || docker network create {{ product.name }} + strip_empty_ends: false + changed_when: false + - name: Create stand ansible.builtin.command: cmd: >- diff --git a/stack/product/compose.j2 b/stack/product/compose.j2 index 669c1ca8..654045af 100644 --- a/stack/product/compose.j2 +++ b/stack/product/compose.j2 @@ -2,9 +2,11 @@ name: {{ product.name }} networks: product_network: + name: {{ product.name }} + external: true configs: - stack_config: + product_config: file: ./{{ product.config.file_name }} {% set storage = product.storages[ops[opsenv].storage.vendor]|combine(ops[opsenv].storage) %} @@ -12,6 +14,8 @@ configs: services: storage: image: {{ storage.image }}:{{ storage.version }}-alpine + networks: + - product_network ports: - 5432:5432 environment: @@ -22,11 +26,11 @@ services: interval: 10s timeout: 5s retries: 5 - networks: - - product_network database: image: {{ image_ns }}/{{ database.image }}:{{ database.cid }} + networks: + - product_network depends_on: storage: condition: service_healthy @@ -45,12 +49,12 @@ services: -Ddatabase.name={{ database.name }} -Downer.username={{ storage.owner.username }} -Downer.password={{ storage.owner.password }} - networks: - - product_network {% for schema in product.schemas[storage.vendor] %} {{ schema.name }}: image: {{ image_ns }}/{{ database.image }}:{{ database.cid }} + networks: + - product_network depends_on: database: condition: service_completed_successfully @@ -66,18 +70,18 @@ services: --password={{ storage.owner.password }} update -Dschema.name={{ schema.name }} - networks: - - product_network {% endfor %} {% set apps = product.apps[ops[opsenv].app.lang]|selectattr('service', 'in', usages[purpose].apps) %} {% for app in apps %} {{ app.service }}: image: {{ image_ns }}/{{ app.image }}:{{ hostvars.app.image_tags[app.binary] }} + networks: + - product_network ports: - 8080:8080 configs: - - source: stack_config + - source: product_config target: /home/app/{{ product.config.file_name }} command: >- --product.config.mapping.mode={{ product.config.mapping_mode }} @@ -89,6 +93,4 @@ services: {% endfor %} labels: image.key: {{ app.image }} - networks: - - product_network {% endfor %}