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

Unable to use generate templates using Python3 on CentOS due to missing libselinux-python package #50983

Closed
matt852 opened this issue Jan 16, 2019 · 5 comments
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@matt852
Copy link

matt852 commented Jan 16, 2019

SUMMARY

I am unable to run the template plugin, and generate a Jinja2 template with variables in it, when using Python3 on a CentOS server.

I believe this is due to the Python3 package 'libselinux-python' not being available for Python 3 on CentOS.
Reference these two links:
https://www.rpmfind.net/linux/rpm2html/search.php?query=libselinux-python
https://www.rpmfind.net/linux/rpm2html/search.php?query=libselinux-python3

ISSUE TYPE
  • Bug Report
COMPONENT NAME

template

ANSIBLE VERSION
ansible 2.7.5
  config file = /home/v1tal3/ansible_playbooks-v1tal3/ansible.cfg
  configured module search path = ['/home/v1tal3/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.5 (default, Apr 10 2018, 17:08:37) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
CONFIGURATION
DEPRECATION_WARNINGS(/home/v1tal3/ansible_playbooks-v1tal3/ansible.cfg) = False
HOST_KEY_CHECKING(/home/v1tal3/ansible_playbooks-v1tal3/ansible.cfg) = False
PERSISTENT_COMMAND_TIMEOUT(/home/v1tal3/ansible_playbooks-v1tal3/ansible.cfg) = 60
OS / ENVIRONMENT

CentOS Linux release 7.5.1804 (Core) running on a VM
$ python --version
Python 2.7.5
$ python3 --version
Python 3.6.5

STEPS TO REPRODUCE

bug.yml:

---
- name: Demonstrate bug with CentOS using Python 3
  hosts: localhost
  gather_facts: false
  vars:
    ansible_python_interpreter: /usr/local/bin/python3

  tasks:
    - name: Create config template (fails)
      template:
        src: bug.j2
        dest: bug.cfg

templates/bug.j2:

test title
host - {{ ansible_host }}
EXPECTED RESULTS

The playbook generates a new file called "bug.cfg" with the following output:

test title
host - 127.0.0.1
ACTUAL RESULTS
$ ansible-playbook bug.yml -vvvv
ansible-playbook 2.7.5
  config file = /home/v1tal3/ansible_playbooks-v1tal3/ansible.cfg
  configured module search path = ['/home/v1tal3/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.5 (default, Apr 10 2018, 17:08:37) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /home/v1tal3/ansible_playbooks-v1tal3/ansible.cfg as config file
setting up inventory plugins
/etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
Parsed /etc/ansible/hosts inventory source with ini plugin
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.6/site-packages/ansible/plugins/callback/default.py

PLAYBOOK: bug.yml ************************************************************************************************************************************************************************************************************************************************************
1 plays in bug.yml

PLAY [Demonstrate bug with CentOS using Python 3] ****************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [Create config template (only works with Python 2 on CentOS, as temporarily set above)] *********************************************************************************************************************************************************************************
task path: /home/v1tal3/ansible_playbooks-v1tal3/bug.yml:15
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: v1tal3
<127.0.0.1> EXEC /bin/sh -c 'echo ~v1tal3 && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183 `" && echo ansible-tmp-1547648558.0866184-208299202320183="` echo /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183 `" ) && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/stat.py
<127.0.0.1> PUT /home/v1tal3/.ansible/tmp/ansible-local-170364t4rllt7/tmp0texp5h9 TO /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/AnsiballZ_stat.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/ /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/AnsiballZ_stat.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/local/bin/python3 /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/AnsiballZ_stat.py && sleep 0'
<127.0.0.1> PUT /home/v1tal3/.ansible/tmp/ansible-local-170364t4rllt7/tmpl85o957k/bug.j2 TO /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/source
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/ /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/source && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/copy.py
<127.0.0.1> PUT /home/v1tal3/.ansible/tmp/ansible-local-170364t4rllt7/tmp8g00vcx_ TO /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/AnsiballZ_copy.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/ /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/AnsiballZ_copy.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/local/bin/python3 /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/AnsiballZ_copy.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "checksum": "4f2f629f95d85b37465004f7b2d55290d405a06d",
    "diff": [],
    "invocation": {
        "module_args": {
            "_original_basename": "bug.j2",
            "attributes": null,
            "backup": false,
            "checksum": "4f2f629f95d85b37465004f7b2d55290d405a06d",
            "content": null,
            "delimiter": null,
            "dest": "bug.cfg",
            "directory_mode": null,
            "follow": false,
            "force": true,
            "group": null,
            "local_follow": null,
            "mode": null,
            "owner": null,
            "regexp": null,
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": "/home/v1tal3/.ansible/tmp/ansible-tmp-1547648558.0866184-208299202320183/source",
            "unsafe_writes": null,
            "validate": null
        }
    },
    "msg": "Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!"
}
  to retry, use: --limit @/home/v1tal3/ansible_playbooks-v1tal3/bug.retry

PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1
@matt852 matt852 changed the title Unable to use generate templates using Python3 on CentOS Unable to use generate templates using Python3 on CentOS due to missing libselinux-python package Jan 16, 2019
@ansibot
Copy link
Contributor

ansibot commented Jan 16, 2019

Files identified in the description:

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

click here for bot help

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jan 16, 2019
@mattclay
Copy link
Member

List Information

Hi!

Thanks very much for your interest in Ansible. It sincerely means a lot to us.

This appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.

If you can stop by there, we'd appreciate it. This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like.

Thank you once again and we look forward to seeing you on the list or IRC. Thanks!

@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label Jan 22, 2019
@ssbarnea
Copy link
Member

I think that this bug is real and we should try to do something about it, even if is not directly Ansible fault that the python3 from centos7 does not have this extension.

@carlwgeorge
Copy link

carlwgeorge commented Jun 28, 2019

Relevant to this discussion, Red Hat is adding python3 in RHEL 7.7 (which will obsolete EPEL's python34 and python36 packages). I asked for libselinux-python3 to be enabled in the libselinux spec file as well, however it sounds like that won't happen in time for 7.7 (maybe 7.8).

Edit: RHEL's upcoming python3 will obsolete python36, and python36 already obsoletes python34.

cc: @hroncok

@hroncok
Copy link
Contributor

hroncok commented Jun 28, 2019

To clarify, it will only obsolete python36.

@ansible ansible locked and limited conversation to collaborators Jul 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

6 participants