English 中文(简体)
Related Docker networks for apps in separate Ansible roles
原标题:

Suppose I m using a webserver / reverse proxy (traefik, nginx, apache, etc.) for various apps. If the webserver and all the apps are in the same docker-compose.yml then it s easy to configure the network, e.g.:

networks:
  traefik-appfoo:
  traefik-appbar:

services

  traefik:
    # ...
    networks:
      - traefik-appfoo
      - traefik-appbar

  appfoo:
    # ...
    networks:
      - traefik-appfoo

  appbar:
    # ...
    networks:
      - traefik-appbar

But that is a simplistic deployment. In reality I have an an ansible playbook with multiple roles:

roles/
 traefik/   # installs and configures traefik
 appfoo/    # installs and configures foo, which is reverse-proxied by traefik
 appbar/    # installs and configures bar, which is reverse-proxied by traefik
 appbaz/    # ...
playbook.yml

Each role has its own docker-compose.yml. So I must somehow pass a network name from the app roles to the traefik role. The traefik role s docker-compose.yml would look like this:

networks:
  ?                         # <----------
  ?                         # <----------

services
  traefik:
    # ...
    networks:
      - ?                   # <----------
      - ?                   # <----------

I don t want to hardcode networks in the traefik role: that is messy, hard to maintain, and roles would not be independent.

In the past when I did this, in each app role I had ansible fragments which were uploaded to some directory on the server, e.g. traefik/docker-compose.yml.d/. And every time I added a new app role, I d have to run a task to assemble the fragments into a complete docker-compose.yml for traefik. If I had to run the original traefik role, it was idempotent as it would reassemble the fragments properly. This approach works, but it s very hard to maintain.

Is there a simpler way to handle this scenario? The same problem would apply for any app with dependent apps (that are installed later, in separate roles).

问题回答

暂无回答




相关问题
Forwarding HTTP Request with Direct Server Return

I have servers spread across several data centers, each storing different files. I want users to be able to access the files on all servers through a single domain and have the individual servers ...

Rails page caching vs. HTTP reverse proxy caches

I ve been catching up with the Scaling Rails screencasts. In episode 11 which covers advanced HTTP caching (using reverse proxy caches such as Varnish and Squid etc.), they recommend only considering ...

ASP.Net reverse proxy, what to do with external resources?

I m currently working on a concept for a reverse proxy to basically relay responses and requests between the user and an otherwise invisible website. So basically the user goes to a site, let s say ...

Tomcat serving URLs wrong with mod_proxy and apache

I ve set up a host with apache to serve static pages and to use Tomcat to serve my web application (See this question). The static pages are server from "http://myhost.com" and the dynamic (tomcat) ...

Perlbal Reproxy with Remote Host

why would perlbal s reproxying give me a 503 for any remote url? X-REPROXY-URL: /path/to/a/local/file.jpg = working X-REPROXy-URL: http://a-public-file-in-an-s3-bucket.jpg = HTTP 503 my perlbal conf ...

Socket Proxy Server

Suppose Client A connects though TCP/IP Sockets to Server B Is it possible to create a Proxy Like Server thing to do this: Client A Connects to Proxy X ; And tried to authenticate to the server (...

热门标签