summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/cloud/lxc
diff options
context:
space:
mode:
authorLucas Alvares Gomes <lucasagomes@gmail.com>2017-08-17 17:01:47 +0100
committeransibot <ansibot@users.noreply.github.com>2017-08-17 12:01:47 -0400
commit119a79cf0c0cff5e78c6d58faf27679417baf4c2 (patch)
tree2fe41243c2aea671b16957052792f093c5eb01dc /lib/ansible/modules/cloud/lxc
parentff4fa6ac29c01135168b4289c99df198ea2a4b31 (diff)
downloadansible-119a79cf0c0cff5e78c6d58faf27679417baf4c2.tar.gz
Replace lxc-clone with lxc-copy (#19890) (#20373)
The command lxc-clone is deprecated in favor of lxc-copy. This patch changes the lxc module to use the new lxc-copy command by default. If not present, it will fallback to the old lxc-clone command to keep it backward compatible with older versions of lxc.
Diffstat (limited to 'lib/ansible/modules/cloud/lxc')
-rw-r--r--lib/ansible/modules/cloud/lxc/lxc_container.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/ansible/modules/cloud/lxc/lxc_container.py b/lib/ansible/modules/cloud/lxc/lxc_container.py
index aef8365c0e..ae8b196f8a 100644
--- a/lib/ansible/modules/cloud/lxc/lxc_container.py
+++ b/lib/ansible/modules/cloud/lxc/lxc_container.py
@@ -477,7 +477,15 @@ LXC_COMMAND_MAP = {
}
},
'clone': {
- 'variables': {
+ 'variables-lxc-copy': {
+ 'backing_store': '--backingstorage',
+ 'lxc_path': '--lxcpath',
+ 'fs_size': '--fssize',
+ 'name': '--name',
+ 'clone_name': '--newname'
+ },
+ # lxc-clone is deprecated in favor of lxc-copy
+ 'variables-lxc-clone': {
'backing_store': '--backingstore',
'lxc_path': '--lxcpath',
'fs_size': '--fssize',
@@ -788,13 +796,20 @@ class LxcContainerManagement(object):
self.state_change = True
self.container.stop()
+ # lxc-clone is deprecated in favor of lxc-copy
+ clone_vars = 'variables-lxc-copy'
+ clone_cmd = self.module.get_bin_path('lxc-copy')
+ if not clone_cmd:
+ clone_vars = 'variables-lxc-clone'
+ clone_cmd = self.module.get_bin_path('lxc-clone', True)
+
build_command = [
- self.module.get_bin_path('lxc-clone', True),
+ clone_cmd,
]
build_command = self._add_variables(
variables_dict=self._get_vars(
- variables=LXC_COMMAND_MAP['clone']['variables']
+ variables=LXC_COMMAND_MAP['clone'][clone_vars]
),
build_command=build_command
)
@@ -810,7 +825,7 @@ class LxcContainerManagement(object):
rc, return_data, err = self._run_command(build_command)
if rc != 0:
- message = "Failed executing lxc-clone."
+ message = "Failed executing %s." % os.path.basename(clone_cmd)
self.failure(
err=err, rc=rc, msg=message, command=' '.join(
build_command