Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #7369/1bf5a44a backport][stable-6] Fix lxc plugin options #7370

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Oct 9, 2023

This is a backport of PR #7369 as merged into main (1bf5a44).

SUMMARY

Because the lxc plugin was only using PlayContext properties, using host vars like ansible_lxc_host didn't work. This is fixed by instead using the get_option method inherited from AnsiblePlugin. The options are not yet available in the __init__ function, so the determination of the container name is moved to the _connect method, which is the first time it is actually needed. The default for the remote_addr option is removed, because the string inventory_hostname is not very useful. At all. This seams to have been spread with copy&paste and a bit of cargo culting. The variable priority already takes care of setting the value.

Add a fixture to allow testing the lxc connection plugin both with and without liblxc being present. Also change the test from unittest to pytest, and add more tests.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lxc

ADDITIONAL INFORMATION

* Fixture for liblxc

Add a fixture to allow testing the lxc connection plugin both with and
without liblxc being present.

Also change the test from unittest to pytest.

* Update liblxc error message

The error is not specific to python2, so remove the version. Also add
a test for it.

* Migrate to options

Because the lxc plugin was only using PlayContext properties, using host
vars like `ansible_lxc_host` didn't work. This is fixed by instead using
the `get_option` method inherited from `AnsiblePlugin`.
The options are not yet available in the `__init__` function, so the
determination of the container name is moved to the `_connect` method,
which is the first time it is actually needed.
The default for the `remote_addr` option is removed, because the string
`inventory_hostname` is not very useful. At all. This seams to have been
spread with copy&paste and a bit of cargo culting. The variable priority
already takes care of setting the value.

* Add changelog fragment

* Fix for Py2.7

`TypeError: super() takes at least 1 argument (0 given)`

* Add plugin type to changelog fragment.

* Restore untemplated default

This partially reverts commit 429d8c8.

---------

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 1bf5a44)
@patchback patchback bot mentioned this pull request Oct 9, 2023
@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug connection connection plugin new_contributor Help guide this first time contributor plugins plugin (any type) tests tests unit tests/unit labels Oct 9, 2023
@felixfontein felixfontein merged commit 02a2575 into stable-6 Oct 9, 2023
@felixfontein felixfontein deleted the patchback/backports/stable-6/1bf5a44a77b4019838bf8bfa9791b7ee85bacaa3/pr-7369 branch October 9, 2023 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug connection connection plugin new_contributor Help guide this first time contributor plugins plugin (any type) tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants