From 337ddf87802c7597b7c51a071eb9829a4b87defa Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 17 Mar 2022 16:24:44 +0100 Subject: [PATCH] Replace systemd-mount template with role To reduce role complexity we replace separatelly maintained template with systemd_mount role that is widely used across OSA. Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/836945 Change-Id: I23632f9c145be334b1d19067352f8b82114a1209 --- files/var-lib-machines.mount | 19 ------------------ handlers/main.yml | 21 -------------------- tasks/lxc_cache_rootfs.yml | 38 +++++++++++++----------------------- 3 files changed, 14 insertions(+), 64 deletions(-) delete mode 100644 files/var-lib-machines.mount diff --git a/files/var-lib-machines.mount b/files/var-lib-machines.mount deleted file mode 100644 index b2d02699..00000000 --- a/files/var-lib-machines.mount +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. - -[Unit] -Description=Virtual Machine and Container Storage -ConditionPathExists=/var/lib/machines.raw - -[Mount] -What=/var/lib/machines.raw -Where=/var/lib/machines -Type=ext4 -Options=loop,defaults,noatime,nodiratime - -[Install] -WantedBy=multi-user.target diff --git a/handlers/main.yml b/handlers/main.yml index edb52879..d41ec398 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -32,27 +32,6 @@ name: "systemd-importd.service" state: "restarted" -- name: Enable machines mount - systemd: - daemon_reload: yes - name: "var-lib-machines.mount" - enabled: "yes" - listen: Start machines mount - -# NOTE(cloudnull): The systemd module is not used to start the -# mount because we dont want to "restart" the -# mount unnecessarily. To ensure we're able to -# load new options without requiring a mount -# restart the systemctl command is used with -# the "reload-or-restart" argument. -- name: Start or reload the machines mount - command: "systemctl reload-or-restart var-lib-machines.mount" - args: - warn: no - listen: Start machines mount - tags: - - skip_ansible_lint - - name: Restart irqbalance systemd: name: "irqbalance" diff --git a/tasks/lxc_cache_rootfs.yml b/tasks/lxc_cache_rootfs.yml index df9d2158..ca1784d3 100644 --- a/tasks/lxc_cache_rootfs.yml +++ b/tasks/lxc_cache_rootfs.yml @@ -26,30 +26,20 @@ when: - machines_create is changed -- name: Create machines mount point - file: - path: "/var/lib/machines" - state: "directory" - recurse: true - -- name: Move machines mount into place - copy: - src: var-lib-machines.mount - dest: /lib/systemd/system/var-lib-machines.mount - register: mount_unit - -- name: Reload the System daemon - systemd: - daemon_reload: yes - when: mount_unit is changed - -- name: Mount all - shell: "mount | grep '/var/lib/machines' || (systemctl start var-lib-machines.mount && exit 3)" - register: mount_machines - changed_when: mount_machines.rc == 3 - failed_when: mount_machines.rc not in [0, 3] - tags: - - skip_ansible_lint +- name: Create systemd mount + import_role: + name: systemd_mount + vars: + systemd_mounts: + - what: '/var/lib/machines.raw' + where: '/var/lib/machines' + type: 'ext4' + options: 'loop' + unit: + ConditionPathExists: + - '/var/lib/machines.raw' + state: 'started' + enabled: true - name: Remove the old image cache file: