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

LXC module uses python2 #5294

Closed
1 task done
Igorgro opened this issue Sep 18, 2022 · 7 comments · Fixed by #5304
Closed
1 task done

LXC module uses python2 #5294

Igorgro opened this issue Sep 18, 2022 · 7 comments · Fixed by #5304
Labels
bug This issue/PR relates to a bug connection connection plugin has_pr module module plugins plugin (any type)

Comments

@Igorgro
Copy link

Igorgro commented Sep 18, 2022

Summary

LXC related modules use python2, which is EOL since 2020 and is not available in modern linux distros.

Issue Type

Bug Report

Component Name

lxc
lxc_container

Ansible Version

$ ansible --version
ansible [core 2.13.4]
  config file = /home/igormahov/dev/ansible/miem/collection/ansible.cfg
  configured module search path = ['/home/igormahov/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/igormahov/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.7 (main, Sep  6 2022, 21:22:27) [GCC 12.2.0]
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /usr/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.6.0  

Configuration

$ ansible-config dump --only-changed

OS / Environment

Arch Linux, but generally it doesn't matter

Steps to Reproduce

Try to connect to LXC host using lxc connection. Sample inventory:

all:
  hosts:
    mylxc:
      ansible_connection: community.general.lxc
      ansible_host: 192.168.123.123
      ansible_user: root

Sample playbook:

- name: Setup VM
  hosts: mylxc
  tasks:
    - name: Debug
      ansible.builtin.debug:
        msg: Hello

Results in error:

fatal: [mylxc]: FAILED! => {"msg": "lxc bindings for python2 are not installed"}

which cannot be resolved because python2 no longer available.
The same porblem is related to lxc_container module which also requires python2 lxc bindings.

Expected Results

It is expected that lxc modue depends on python3 lxc binding rather than python2.

Actual Results

No response

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot ansibullbot added bug This issue/PR relates to a bug connection connection plugin plugins plugin (any type) labels Sep 18, 2022
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added the module module label Sep 18, 2022
@cloudnull
Copy link
Contributor

@Igorgro the error message is wrong and needs to be updated. The module requires python3-lxc for modern linux distros. Just make sure you have that package installed and it should work.

cloudnull added a commit to cloudnull/community.general that referenced this issue Sep 23, 2022
This change is mostly just a documentation change which will report the requirements
correctly for python3-lxc. I've also removed the use of six which results in us
changing `xrange` to `range`.

Resolves: ansible-collections#5294
Signed-off-by: Kevin Carter <[email protected]>
@russoz
Copy link
Collaborator

russoz commented Sep 25, 2022

@cloudnull that specific message comes from the lxc connection plugin, not from the lxc_container module. See:
https://github.com/ansible-collections/community.general/blob/main/plugins/connection/lxc.py#L70

@Igorgro the plugin does not seem to check specifically for Python 2 or 3, so regardless of any error message and regardless of having installed the package in the Python3, you have to ensure that Ansible is executing Python 3 on the target node - if that's what you want. Please keep in mind that despite thefact that Python 2 itself is no longer supported, that version is still, in theory, supported by Ansible and by this collection.

@Igorgro
Copy link
Author

Igorgro commented Sep 25, 2022

@russoz
Copy link
Collaborator

russoz commented Sep 25, 2022

Those docs are generated automatically from the source code. ;)

cloudnull added a commit to cloudnull/community.general that referenced this issue Sep 29, 2022
This change is mostly just a documentation change which will report the requirements
correctly for python3-lxc. I've also removed the use of six which results in us
changing `xrange` to `range`.

Resolves: ansible-collections#5294
Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>
felixfontein added a commit that referenced this issue Oct 1, 2022
* chore: Update lxc_container to support py3

This change is mostly just a documentation change which will report the requirements
correctly for python3-lxc. I've also removed the use of six which results in us
changing `xrange` to `range`.

Resolves: #5294
Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update 5280-lxc_container-py3.yaml

* Update 5280-lxc_container-py3.yaml

Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>
Co-authored-by: Felix Fontein <[email protected]>
patchback bot pushed a commit that referenced this issue Oct 1, 2022
* chore: Update lxc_container to support py3

This change is mostly just a documentation change which will report the requirements
correctly for python3-lxc. I've also removed the use of six which results in us
changing `xrange` to `range`.

Resolves: #5294
Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update 5280-lxc_container-py3.yaml

* Update 5280-lxc_container-py3.yaml

Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>
Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 2eba5dc)
felixfontein pushed a commit that referenced this issue Oct 1, 2022
* chore: Update lxc_container to support py3

This change is mostly just a documentation change which will report the requirements
correctly for python3-lxc. I've also removed the use of six which results in us
changing `xrange` to `range`.

Resolves: #5294
Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update 5280-lxc_container-py3.yaml

* Update 5280-lxc_container-py3.yaml

Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>
Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 2eba5dc)

Co-authored-by: Kevin Carter <[email protected]>
bratwurzt pushed a commit to bratwurzt/community.general that referenced this issue Nov 7, 2022
* chore: Update lxc_container to support py3

This change is mostly just a documentation change which will report the requirements
correctly for python3-lxc. I've also removed the use of six which results in us
changing `xrange` to `range`.

Resolves: ansible-collections#5294
Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update 5280-lxc_container-py3.yaml

* Update 5280-lxc_container-py3.yaml

Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>
Co-authored-by: Felix Fontein <[email protected]>
bratwurzt pushed a commit to bratwurzt/community.general that referenced this issue Nov 7, 2022
* chore: Update lxc_container to support py3

This change is mostly just a documentation change which will report the requirements
correctly for python3-lxc. I've also removed the use of six which results in us
changing `xrange` to `range`.

Resolves: ansible-collections#5294
Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Alexei Znamensky <[email protected]>

* Update changelogs/fragments/5280-lxc_container-py3.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update 5280-lxc_container-py3.yaml

* Update 5280-lxc_container-py3.yaml

Signed-off-by: Kevin Carter <[email protected]>
Co-authored-by: Alexei Znamensky <[email protected]>
Co-authored-by: Felix Fontein <[email protected]>
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 has_pr module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants