From 0353887590b994cba0840db75c6baebeb0d3de10 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 21 Dec 2020 21:37:46 +0000 Subject: [PATCH] Add override to ensure ZFS starts before docker Stolen with love from https://github.com/IronicBadger/infra/commit/7dda0bc7cbb9a38e17561c80f40f518b9f472ef7 --- ansible/host_vars/intersect.yml | 2 ++ ansible/host_vars/walker.yml | 1 + ansible/roles/docker_cleanup/defaults/main.yml | 1 + .../roles/docker_cleanup/files/zfs-override.conf | 3 +++ ansible/roles/docker_cleanup/tasks/main.yml | 4 ++++ .../roles/docker_cleanup/tasks/zfs-override.yml | 15 +++++++++++++++ 6 files changed, 26 insertions(+) create mode 100644 ansible/host_vars/walker.yml create mode 100644 ansible/roles/docker_cleanup/defaults/main.yml create mode 100644 ansible/roles/docker_cleanup/files/zfs-override.conf create mode 100644 ansible/roles/docker_cleanup/tasks/zfs-override.yml diff --git a/ansible/host_vars/intersect.yml b/ansible/host_vars/intersect.yml index e6b78d2..acaf580 100644 --- a/ansible/host_vars/intersect.yml +++ b/ansible/host_vars/intersect.yml @@ -1,3 +1,5 @@ expose_ssh: true traefik_influx_db_dir: /mnt/tank/dbs/influx/traefik + +docker_zfs_override: true diff --git a/ansible/host_vars/walker.yml b/ansible/host_vars/walker.yml new file mode 100644 index 0000000..e960475 --- /dev/null +++ b/ansible/host_vars/walker.yml @@ -0,0 +1 @@ +docker_zfs_override: true diff --git a/ansible/roles/docker_cleanup/defaults/main.yml b/ansible/roles/docker_cleanup/defaults/main.yml new file mode 100644 index 0000000..acf631b --- /dev/null +++ b/ansible/roles/docker_cleanup/defaults/main.yml @@ -0,0 +1 @@ +docker_zfs_override: false diff --git a/ansible/roles/docker_cleanup/files/zfs-override.conf b/ansible/roles/docker_cleanup/files/zfs-override.conf new file mode 100644 index 0000000..19d01b6 --- /dev/null +++ b/ansible/roles/docker_cleanup/files/zfs-override.conf @@ -0,0 +1,3 @@ +[Unit] +Requires=zfs.target +After=zfs.target diff --git a/ansible/roles/docker_cleanup/tasks/main.yml b/ansible/roles/docker_cleanup/tasks/main.yml index d84b8c3..6153783 100644 --- a/ansible/roles/docker_cleanup/tasks/main.yml +++ b/ansible/roles/docker_cleanup/tasks/main.yml @@ -44,3 +44,7 @@ dest: "{{ home }}" mode: 0755 directory_mode: 0755 + +- name: override docker service for zfs dependencies + include: zfs-override.yml + when: docker_zfs_override diff --git a/ansible/roles/docker_cleanup/tasks/zfs-override.yml b/ansible/roles/docker_cleanup/tasks/zfs-override.yml new file mode 100644 index 0000000..6921838 --- /dev/null +++ b/ansible/roles/docker_cleanup/tasks/zfs-override.yml @@ -0,0 +1,15 @@ +- name: Create dir for docker service ZFS override + file: + path: /etc/systemd/system/docker.service.d + state: directory + mode: "0755" + become: true + +- name: Create override.conf + copy: + src: files/zfs-override.conf + dest: /etc/systemd/system/docker.service.d/zfs-override.conf + owner: root + group: root + mode: "0644" + become: true