97 lines
3.0 KiB
YAML
97 lines
3.0 KiB
YAML
---
|
|
# Copyright 2017, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Check machinectl mount point
|
|
command: mountpoint /var/lib/machines
|
|
failed_when: false
|
|
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
|
|
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
|
|
|
|
- name: Disable the machinectl quota system
|
|
block:
|
|
- name: Disable the machinectl quota system
|
|
command: "btrfs quota {{ nspawn_host_machine_quota_disabled | bool | ternary('disable', 'enabled') }} /var/lib/machines"
|
|
changed_when: false
|
|
register: machines_create
|
|
args:
|
|
executable: /bin/bash
|
|
rescue:
|
|
- name: Notice quota system was not disabled
|
|
debug:
|
|
msg: >-
|
|
The machinectl quota system could not be disabled. This typically
|
|
means it is already off or not available on the system.
|
|
|
|
- name: Systemd machinectl mount
|
|
block:
|
|
- name: Format the machines sparse file
|
|
filesystem:
|
|
fstype: btrfs
|
|
dev: /var/lib/machines.raw
|
|
|
|
- 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: /etc/systemd/system/var-lib-machines.mount
|
|
register: mount_unit
|
|
notify:
|
|
- Reload systemd units
|
|
- Restart machines mount
|
|
|
|
- name: Move machined service into place
|
|
copy:
|
|
src: systemd-machined.service
|
|
dest: /etc/systemd/system/systemd-machined.service
|
|
register: machined_unit
|
|
notify:
|
|
- Reload systemd units
|
|
- Restart machined
|
|
when:
|
|
- machinectl_mount.rc != 0
|
|
|
|
- meta: flush_handlers
|
|
|
|
# NOTE(cloudnull): Because the machines mount may be a manually created sparse
|
|
# file we run an online resize to ensure the machines mount is
|
|
# the size we expect.
|
|
- name: Ensure the machines fs is sized correctly
|
|
command: "btrfs filesystem resize max /var/lib/machines"
|
|
changed_when: false
|
|
failed_when: false
|
|
when:
|
|
- machines_create | changed
|