Skip to content
Snippets Groups Projects
Commit 9313e0a8 authored by ale's avatar ale
Browse files

We no longer need to restart containers to pick up changes in /etc/hosts

parent 25842fcb
Branches
No related tags found
No related merge requests found
......@@ -69,28 +69,3 @@
- debug:
msg: "Failed to clean up containers"
# Restart containers that have an old /etc/hosts file, to update their
# service discovery.
- name: Restart containers with an old /etc/hosts
block:
- stat:
path: "/etc/hosts"
register: etc_hosts_stat
- name: Find containers that need a restart
shell: "{{ container_runtime }} ps --format={% raw %}'{{.Names}} {{.Created}}'{% endraw %} | sed -e 's,[-+][0-9]* [A-Z]*$,,' | while read name d t ; do s=$(date --date=\"$d $t\" +%s); echo \"$name $s\"; done | awk '$2 < {{ etc_hosts_stat.stat.mtime | int }} {print $1}'"
register: containers_to_restart
changed_when: false
check_mode: no
- name: Restart containers with an old /etc/hosts
systemd:
name: "docker-{{ item }}.service"
state: restarted
loop: "{{ containers_to_restart.stdout_lines }}"
rescue:
- debug:
msg: "Failed to restart containers with old /etc/hosts"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment