tasks: container_create: Use lxc-clone as fallback to lxc-copy
lxc-copy is only available to lxc >= 2.0.0 so we need to use the deprecated lxc-clone tool for older lxc releases. Change-Id: I8513ac7c68f5e2865ff0532ad9409c3ec4c0ab9d
This commit is contained in:
parent
e88e41c4af
commit
b8026ad402
|
@ -102,7 +102,12 @@
|
||||||
# the '-B' option is used, instead of the more understandable
|
# the '-B' option is used, instead of the more understandable
|
||||||
# '--backingstore'.
|
# '--backingstore'.
|
||||||
# TODO(odyssey4me): Revisit this once a fix has merged
|
# TODO(odyssey4me): Revisit this once a fix has merged
|
||||||
- name: Create container (copy-on-write backing store)
|
# NOTE(hwoarang) lxc-copy is only available since lxc-2.0.0 so emulate
|
||||||
|
# its behavior using the old lxc-clone command. This is only a problem
|
||||||
|
# on openSUSE so it's safe to remove it when lxc-2.X becomes the default
|
||||||
|
# option for openSUSE in the openstack-ansible-lxc_hosts role.
|
||||||
|
- block:
|
||||||
|
- name: Create container (copy-on-write backing store)
|
||||||
command: >
|
command: >
|
||||||
lxc-copy --snapshot -B {{ lxc_container_backing_store }}
|
lxc-copy --snapshot -B {{ lxc_container_backing_store }}
|
||||||
--name {{ lxc_container_base_name }}
|
--name {{ lxc_container_base_name }}
|
||||||
|
@ -111,6 +116,17 @@
|
||||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||||
delegate_to: "{{ physical_host }}"
|
delegate_to: "{{ physical_host }}"
|
||||||
|
rescue:
|
||||||
|
# NOTE(hwoarang) lxc-clone does not support the common
|
||||||
|
# --logfile/logpriority options so we just redirect everything to the log
|
||||||
|
# which is probably the best we can do.
|
||||||
|
- name: Create container (copy-on-write backing store) (fallback)
|
||||||
|
shell: >
|
||||||
|
lxc-clone -s -B {{ lxc_container_backing_store }} -L {{ properties.container_fs_size | default(lxc_container_fs_size) }}
|
||||||
|
{{ lxc_container_base_name }} {{ inventory_hostname }} &>>
|
||||||
|
{{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||||
|
delegate_to: "{{ physical_host }}"
|
||||||
|
|
||||||
when: >
|
when: >
|
||||||
(lxc_container_backing_store == "overlayfs" or
|
(lxc_container_backing_store == "overlayfs" or
|
||||||
(lxc_container_backing_store == 'lvm' and
|
(lxc_container_backing_store == 'lvm' and
|
||||||
|
|
Loading…
Reference in New Issue