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 <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-06-12 10:27:55 -05:00 committed by Kevin Carter (cloudnull)
parent cfb3f9e7cd
commit 30477c0f89
1 changed files with 10 additions and 19 deletions

View File

@ -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: