Add option to set the machine image cache size

This change adds the option `lxc_host_machine_volume_size` which allows
a deployer to set the image cache size, in gigabytes to something mat
meets their needs. The default value for this option is 16

Change-Id: Ib67da9f203806264c39fc73cc7575ee5acf39e5e
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2017-04-21 10:48:35 -05:00
parent 89625e66b0
commit 18fdecd9d3
3 changed files with 31 additions and 4 deletions

View File

@ -28,6 +28,9 @@ lxc_architecture_mapping:
x86_64: amd64
ppc64le: ppc64el
# Set the volume size in gigabytes for the machine image caches.
lxc_host_machine_volume_size: 8
# lxc container rootfs directory and cache path
lxc_container_directory: "/var/lib/lxc"
lxc_container_cache_path: "/var/cache/lxc/download"

View File

@ -23,6 +23,22 @@
when:
- lxc_image_cache_refresh | bool
# NOTE(cloudnull): When modern SystemD is running everywhere this can be
# collapsed back into the base preparation task file.
- name : Set volume size
shell: |
if [[ ! "$(ls -lh /var/lib/machines.raw | awk '{print $5}')" == "{{ lxc_host_machine_volume_size }}G" ]]; then
machinectl set-limit {{ lxc_host_machine_volume_size }}G
exit 3
else
exit 0
fi
register: machines_create
changed_when: machines_create.rc == 3
failed_when: machines_create.rc not in [0, 3]
when:
- lxc_image_cache_refresh | bool
- name: Retrieve base image
command: >-
machinectl

View File

@ -18,11 +18,19 @@
# ==============================================================
# In later versions of SystemD this is automatically done for us
# by the machinectl cli on first run.
- name: Create sparse machines file
command: "truncate -s 11G /var/lib/machines.raw"
args:
creates: /var/lib/machines.raw
- name : Create volume
shell: |
if [[ ! "$(ls -lh /var/lib/machines.raw | awk '{print $5}')" == "{{ lxc_host_machine_volume_size }}G" ]]; then
if [[ ! -f "/var/lib/machines.raw" ]]; then
truncate -s {{ lxc_host_machine_volume_size }}G /var/lib/machines.raw
exit 3
fi
fi
register: machines_create
changed_when: machines_create.rc == 3
failed_when: machines_create.rc not in [0, 3]
when:
- lxc_image_cache_refresh | bool
# In later versions of SystemD this is automatically done for us
# by the machinectl cli on first run.