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
pull/51938/head
qw34ty 6 years ago committed by John R Barker
parent 861b7742fd
commit 8724c0deda

@ -106,6 +106,12 @@ options:
- The unix domain socket path or the https URL for the LXD server. - The unix domain socket path or the https URL for the LXD server.
required: false required: false
default: unix:/var/lib/lxd/unix.socket 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: key_file:
description: description:
- The client certificate key file path. - The client certificate key file path.
@ -292,10 +298,18 @@ class LXDContainerManagement(object):
self.force_stop = self.module.params['force_stop'] self.force_stop = self.module.params['force_stop']
self.addresses = None self.addresses = None
self.url = self.module.params['url']
self.key_file = self.module.params.get('key_file', None) self.key_file = self.module.params.get('key_file', None)
self.cert_file = self.module.params.get('cert_file', None) self.cert_file = self.module.params.get('cert_file', None)
self.debug = self.module._verbosity >= 4 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: try:
self.client = LXDClient( self.client = LXDClient(
self.url, key_file=self.key_file, cert_file=self.cert_file, self.url, key_file=self.key_file, cert_file=self.cert_file,
@ -583,6 +597,10 @@ def main():
type='str', type='str',
default='unix:/var/lib/lxd/unix.socket' default='unix:/var/lib/lxd/unix.socket'
), ),
snap_url=dict(
type='str',
default='unix:/var/snap/lxd/common/lxd/unix.socket'
),
key_file=dict( key_file=dict(
type='str', type='str',
default='{0}/.config/lxc/client.key'.format(os.environ['HOME']) default='{0}/.config/lxc/client.key'.format(os.environ['HOME'])

@ -67,6 +67,12 @@ options:
- The unix domain socket path or the https URL for the LXD server. - The unix domain socket path or the https URL for the LXD server.
required: false required: false
default: unix:/var/lib/lxd/unix.socket 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: key_file:
description: description:
- The client certificate key file path. - The client certificate key file path.
@ -199,10 +205,18 @@ class LXDProfileManagement(object):
self.state = self.module.params['state'] self.state = self.module.params['state']
self.new_name = self.module.params.get('new_name', None) 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.key_file = self.module.params.get('key_file', None)
self.cert_file = self.module.params.get('cert_file', None) self.cert_file = self.module.params.get('cert_file', None)
self.debug = self.module._verbosity >= 4 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: try:
self.client = LXDClient( self.client = LXDClient(
self.url, key_file=self.key_file, cert_file=self.cert_file, self.url, key_file=self.key_file, cert_file=self.cert_file,
@ -352,6 +366,10 @@ def main():
type='str', type='str',
default='unix:/var/lib/lxd/unix.socket' default='unix:/var/lib/lxd/unix.socket'
), ),
snap_url=dict(
type='str',
default='unix:/var/snap/lxd/common/lxd/unix.socket'
),
key_file=dict( key_file=dict(
type='str', type='str',
default='{0}/.config/lxc/client.key'.format(os.environ['HOME']) default='{0}/.config/lxc/client.key'.format(os.environ['HOME'])

Loading…
Cancel
Save