Handle remote_addr change in lxc connection plugin (#7373)

* Stopped container error test

* Handle remote_addr change

Detect if the remote_addr option changed, and properly "reconnect" aka
update the internal state of the plugin instance.

* Add changelog fragment

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Corubba 2023-10-18 20:54:24 +02:00 committed by GitHub
parent 33133f3ba9
commit 3ae19aa28f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 4 deletions

View file

@ -71,10 +71,11 @@ class Connection(ConnectionBase):
msg = "lxc python bindings are not installed"
raise errors.AnsibleError(msg)
if self.container:
container_name = self.get_option('remote_addr')
if self.container and self.container_name == container_name:
return
self.container_name = self.get_option('remote_addr')
self.container_name = container_name
self._display.vvv("THIS IS A LOCAL LXC DIR", host=self.container_name)
self.container = _lxc.Container(self.container_name)