diff --git a/handlers/main.yml b/handlers/main.yml index cbd9210..7961bb8 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -42,10 +42,6 @@ state: absent changed_when: false -- name: Create tmpfiles structure in journald - command: "systemd-tmpfiles --create --prefix /var/log/journal" - changed_when: false - - name: Restart systemd-journald systemd: name: "systemd-journald" diff --git a/tasks/main.yml b/tasks/main.yml index cd97896..67d4e66 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -35,6 +35,8 @@ tags: - always +# NOTE(cloudnull): Because DNSMasq will be installed this task is required to +# ensure we're never starting that service in an unknown state. - name: Prevent service from starting on install copy: content: | @@ -73,8 +75,6 @@ - /etc/systemd/network - /etc/systemd/journald.conf.d - /var/log/journal - notify: - - Create tmpfiles structure in journald - name: Create journald directories file: @@ -85,23 +85,12 @@ mode: "02755" with_items: - /var/log/journal - notify: - - Create tmpfiles structure in journald - -- name: Create journald tempfiles - template: - src: "systemd-journald-tmpfiles.j2" - dest: "/etc/tmpfiles.d/systemd-journald.conf" - notify: - - Create tmpfiles structure in journald - - Restart systemd-journald - name: Create journald tempfiles template: src: "systemd-journald-nspawn_host.conf.j2" dest: "/etc/systemd/journald.conf.d/systemd-journald-nspawn_host.conf" notify: - - Create tmpfiles structure in journald - Restart systemd-journald - include: nspawn_cache_prestage.yml diff --git a/tasks/nspawn_cache.yml b/tasks/nspawn_cache.yml index ccac686..081c0c5 100644 --- a/tasks/nspawn_cache.yml +++ b/tasks/nspawn_cache.yml @@ -109,11 +109,6 @@ when: - nspawn_image_cache_refresh | bool -- name: Create networkd directory - file: - path: "/var/lib/machines/{{ nspawn_container_base_name }}/etc/systemd/network" - state: directory - - name: Create static MACs in the container copy: src: "/etc/systemd/network/99-default.link" diff --git a/templates/prep-scripts/_container_sys_setup.sh.j2 b/templates/prep-scripts/_container_sys_setup.sh.j2 index e66a12c..aaaab85 100644 --- a/templates/prep-scripts/_container_sys_setup.sh.j2 +++ b/templates/prep-scripts/_container_sys_setup.sh.j2 @@ -17,6 +17,12 @@ mkdir -p /etc/ansible/facts.d # Create the backups directory mkdir -p /var/backup +# Create networkd directory +mkdir -p /etc/systemd/network + +# Remove the journal directory +rm -rf /var/log/journal || true + # Create the cache resolvers rm /etc/resolv.conf || true {% for resolver in nspawn_cache_prep_dns %} diff --git a/templates/systemd-journald-tmpfiles.j2 b/templates/systemd-journald-tmpfiles.j2 deleted file mode 100644 index 73ab784..0000000 --- a/templates/systemd-journald-tmpfiles.j2 +++ /dev/null @@ -1,3 +0,0 @@ -# {{ ansible_managed }} - -D /var/log/journal 0755 root systemd-journal diff --git a/templates/systemd-nspawn@.service.j2 b/templates/systemd-nspawn@.service.j2 index b51bdc2..61b5e39 100644 --- a/templates/systemd-nspawn@.service.j2 +++ b/templates/systemd-nspawn@.service.j2 @@ -1,3 +1,5 @@ +# {{ ansible_managed }} + # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it @@ -11,9 +13,13 @@ Documentation=man:systemd-nspawn(1) PartOf=machines.target Before=machines.target After=network.target +After=network-online.target +After=systemd-networkd.service +After=nspawn-macvlan.service +Wants=network-online.target [Service] -ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-veth {{ (nspawn_systemd_version | int > 219) | ternary('--settings=override --machine=%I', '--machine=%I') }} +ExecStart=/usr/bin/systemd-nspawn --keep-unit --boot --link-journal=try-host {{ (nspawn_systemd_version | int > 219) | ternary('--settings=override --machine=%I', '--machine=%I') }} KillMode=mixed Type=notify RestartForceExitStatus=133