From 30477c0f89f51afb57e8bc282f1d156d9dd02413 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 12 Jun 2018 10:27:55 -0500 Subject: [PATCH] tasks: Always create the machines.raw file The machines.raw file is only created if the 'machinectl set-limit' command returns non-zero exit code. However, this file is expected to be present later on so we need to make sure that we create without taking the 'machinectl' exit code into consideration. Fixes the following problem: Change-Id: If96c870d317bc7a024169ffd04e8f4c10003ba74 fatal: [localhost]: FAILED! => {"changed": false, "msg": "Device /var/lib/machines.raw not found."} Signed-off-by: Kevin Carter --- tasks/nspawn_volume.yml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/tasks/nspawn_volume.yml b/tasks/nspawn_volume.yml index f4890b5..7b4336d 100644 --- a/tasks/nspawn_volume.yml +++ b/tasks/nspawn_volume.yml @@ -19,25 +19,16 @@ changed_when: false register: machinectl_mount -- name: Create systemd sparse file - block: - - name: Set volume size - shell: machinectl set-limit {{ nspawn_host_machine_volume_size }} - changed_when: false - register: machines_create - args: - executable: /bin/bash - tags: - - skip_ansible_lint - rescue: - - name: Create volume file (fallback) - shell: | - truncate -s '>{{ nspawn_host_machine_volume_size }}' /var/lib/machines.raw - register: machines_create - args: - executable: /bin/bash - tags: - - skip_ansible_lint +- name: Set the machinectl limit + shell: | + machinectl set-limit {{ nspawn_host_machine_volume_size }} + truncate -s '>{{ nspawn_host_machine_volume_size }}' /var/lib/machines.raw + changed_when: false + register: machines_create + args: + executable: /bin/bash + tags: + - skip_ansible_lint - name: Systemd machinectl mount block: