Commit b8fd1d62 authored by ale's avatar ale

Stop using separate env files in /etc/default for containers

This is just adding complexity, instead define the variables directly
in the run script.

Also fixes an issue where containers were not restarted when the
environment changed.
parent d0e7aac8
Pipeline #6237 failed with stage
in 4 minutes and 52 seconds
......@@ -26,10 +26,12 @@
append: true
loop: "{{ float_enabled_containers }}"
- name: Configure container environments
# TODO: get rid of this once the existing environments have been updated!
- name: Remove obsolete container environment files
file:
template:
src: env.j2
dest: "/etc/default/{{ item.service }}-{{ item.container.name }}"
path: "/etc/default/{{ item.service }}-{{ item.container.name }}"
state: absent
loop: "{{ float_enabled_containers }}"
- name: Create run scripts
......
HOSTNAME="{{ ansible_hostname }}"
PUBLIC_ADDR="{{ ansible_hostname }}"
USER="docker-{{ item.service }}"
{% for k, v in item.container.get('env', {}) | dictsort %}
{{ k }}="{{ v }}"
{% endfor %}
#!/bin/sh
# Start the docker container for {{ item.service }}-{{ item.container.name }}.
# Environment variables.
export HOSTNAME="{{ ansible_hostname }}"
export PUBLIC_ADDR="{{ ansible_hostname }}"
export USER="docker-{{ item.service }}"
{% for k, v in item.container.get('env', {}) | dictsort %}
export {{ k }}="{{ v }}"
{% endfor %}
{# Macro to generate command-line options #}
{% macro opt(name, value) %}
opts="$opts --{{ name }}={{ value }}"
......
......@@ -6,7 +6,6 @@ Requires=docker.service
{% endif %}
[Service]
EnvironmentFile=-/etc/default/{{ item.service }}-{{ item.container.name }}
ExecStart=/usr/lib/float/docker/run-{{ item.service }}-{{ item.container.name }}.sh
ExecStop=/usr/bin/docker stop {{ item.service }}-{{ item.container.name }}
TimeoutStopSec=60
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment