Commit f68537ea authored by nimrod's avatar nimrod
Browse files

Restart stopped containers after a restart.

parent 716d4438
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
#!/bin/sh
set -eu

docker container list \
    --filter 'label=com.docker.compose.project' \
    --filter 'status=exited' \
    --format '{{ .ID }}' |  xargs -tr docker start
+4 −0
Original line number Original line Diff line number Diff line
---
---
- name: Systemd daemon reload
  ansible.builtin.systemd:
    daemon_reload: true

- name: Rebuild initramfs
- name: Rebuild initramfs
  command:
  command:
    cmd: update-initramfs -u
    cmd: update-initramfs -u
+22 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,28 @@
      - ufw
      - ufw
    state: present
    state: present


- name: Copy the script to start stopped container after a restart
  copy:
    dest: /usr/share/docker.io/restart-containers
    mode: preserve
    src: docker-restart

- name: Create a drop-in directory for the Docker service
  file:
    path: /etc/systemd/system/docker.service.d
    mode: 0o0755
    state: directory

- name: Restart stopped containers after a restart
  copy:
    content: |
      [Service]
      ExecStartPost=/usr/share/docker.io/restart-containers
    dest: /etc/systemd/system/docker.service.d/restart-containers.conf
    mode: 0o0644
  notify:
    - Systemd daemon reload

- name: Rate limit SSH
- name: Rate limit SSH
  community.general.ufw:
  community.general.ufw:
    rule: limit
    rule: limit