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:
parent
89625e66b0
commit
18fdecd9d3
|
@ -28,6 +28,9 @@ lxc_architecture_mapping:
|
||||||
x86_64: amd64
|
x86_64: amd64
|
||||||
ppc64le: ppc64el
|
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 rootfs directory and cache path
|
||||||
lxc_container_directory: "/var/lib/lxc"
|
lxc_container_directory: "/var/lib/lxc"
|
||||||
lxc_container_cache_path: "/var/cache/lxc/download"
|
lxc_container_cache_path: "/var/cache/lxc/download"
|
||||||
|
|
|
@ -23,6 +23,22 @@
|
||||||
when:
|
when:
|
||||||
- lxc_image_cache_refresh | bool
|
- 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
|
- name: Retrieve base image
|
||||||
command: >-
|
command: >-
|
||||||
machinectl
|
machinectl
|
||||||
|
|
|
@ -18,11 +18,19 @@
|
||||||
# ==============================================================
|
# ==============================================================
|
||||||
# In later versions of SystemD this is automatically done for us
|
# In later versions of SystemD this is automatically done for us
|
||||||
# by the machinectl cli on first run.
|
# by the machinectl cli on first run.
|
||||||
- name: Create sparse machines file
|
- name : Create volume
|
||||||
command: "truncate -s 11G /var/lib/machines.raw"
|
shell: |
|
||||||
args:
|
if [[ ! "$(ls -lh /var/lib/machines.raw | awk '{print $5}')" == "{{ lxc_host_machine_volume_size }}G" ]]; then
|
||||||
creates: /var/lib/machines.raw
|
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
|
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
|
# In later versions of SystemD this is automatically done for us
|
||||||
# by the machinectl cli on first run.
|
# by the machinectl cli on first run.
|
||||||
|
|
Loading…
Reference in New Issue