1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

lxd_container fix to check for snap package install unix.socket #34924 (#51541)

* -added simple check to check snap unix.socket #34924

* fixed whitespacing around assignment

* documented snap_url variable

* documented snap_url variable

* documented snap_var

* updaed snap_var doc

* version_added: to documenation

* -updated check method to more reliable approach

* -fixed whitespace missing in replace
This commit is contained in:
qw34ty 2019-02-22 09:24:07 +00:00 committed by John R Barker
parent 861b7742fd
commit 8724c0deda
2 changed files with 38 additions and 2 deletions

View file

@ -106,6 +106,12 @@ options:
- The unix domain socket path or the https URL for the LXD server.
required: false
default: unix:/var/lib/lxd/unix.socket
snap_url:
description:
- The unix domain socket path when LXD is installed by snap package manager.
required: false
default: unix:/var/snap/lxd/common/lxd/unix.socket
version_added: '2.8'
key_file:
description:
- The client certificate key file path.
@ -292,10 +298,18 @@ class LXDContainerManagement(object):
self.force_stop = self.module.params['force_stop']
self.addresses = None
self.url = self.module.params['url']
self.key_file = self.module.params.get('key_file', None)
self.cert_file = self.module.params.get('cert_file', None)
self.debug = self.module._verbosity >= 4
try:
if os.path.exists(self.module.params['snap_url'].replace('unix:', '')):
self.url = self.module.params['snap_url']
else:
self.url = self.module.params['url']
except Exception as e:
self.module.fail_json(msg=e.msg)
try:
self.client = LXDClient(
self.url, key_file=self.key_file, cert_file=self.cert_file,
@ -583,6 +597,10 @@ def main():
type='str',
default='unix:/var/lib/lxd/unix.socket'
),
snap_url=dict(
type='str',
default='unix:/var/snap/lxd/common/lxd/unix.socket'
),
key_file=dict(
type='str',
default='{0}/.config/lxc/client.key'.format(os.environ['HOME'])

View file

@ -67,6 +67,12 @@ options:
- The unix domain socket path or the https URL for the LXD server.
required: false
default: unix:/var/lib/lxd/unix.socket
snap_url:
description:
- The unix domain socket path when LXD is installed by snap package manager.
required: false
default: unix:/var/snap/lxd/common/lxd/unix.socket
version_added: '2.8'
key_file:
description:
- The client certificate key file path.
@ -199,10 +205,18 @@ class LXDProfileManagement(object):
self.state = self.module.params['state']
self.new_name = self.module.params.get('new_name', None)
self.url = self.module.params['url']
self.key_file = self.module.params.get('key_file', None)
self.cert_file = self.module.params.get('cert_file', None)
self.debug = self.module._verbosity >= 4
try:
if os.path.exists(self.module.params['snap_url'].replace('unix:', '')):
self.url = self.module.params['snap_url']
else:
self.url = self.module.params['url']
except Exception as e:
self.module.fail_json(msg=e.msg)
try:
self.client = LXDClient(
self.url, key_file=self.key_file, cert_file=self.cert_file,
@ -352,6 +366,10 @@ def main():
type='str',
default='unix:/var/lib/lxd/unix.socket'
),
snap_url=dict(
type='str',
default='unix:/var/snap/lxd/common/lxd/unix.socket'
),
key_file=dict(
type='str',
default='{0}/.config/lxc/client.key'.format(os.environ['HOME'])