A key challenge is managing the configuration of services that depend on other dynamic services.

After they are deployed, the nginx configuration needs to change to point to the new backend containers.

What do you do with nginx? Do you change the its configuration, build a new container and deploy it? What if there was a way for you to automatically detect the changes on the backend service and dynamically update nginx? That’s where Rancher-Gen comes into play.

Below is a tutorial that describes how to automatically generate an nginx configuration file for a backend service running the ghost blogging platform.

All configuration files described below can be found under the demo directory in the Rancher-Gen repository.

9.17 MAINTAINER pitrho # Step 1 – Install nginx and python ENV DEBIAN FRONTEND noninteractive RUN apt-add-repository -y ppa:nginx/stable && apt-get update && apt-get install -y python-software-properties wget nginx python-dev python-pip libev4 libev-dev expect-dev && rm -rf /var/lib/apt/lists/* && chown -R www-data:www-data /var/lib/nginx && apt-get clean # Step 2 – Install rancher-gen ENV RANCHER GEN VERSION 0.1.2 RUN pip install rancher-gen==$RANCHER GEN VERSION # Step 3 – Define services RUN mkdir /etc/service/nginx /etc/service/rancher gen /nginxconf COPY nginx run /etc/service/nginx/run COPY rancher-gen run /etc/service/rancher gen/run COPY default.

With the expressiveness of Jinja2 templates, and its clean command line interface, Rancher-Gen can be used to generate most configuration files, and automate tasks that otherwise would be tedious and repetitive for most sysadmins and software engineers.